Fixing tabs and indents - no code change

Change-Id: I4b889b5393ae0ee96165286d72a9e104c17fd4c8
diff --git a/src/main/java/net/floodlightcontroller/core/internal/Controller.java b/src/main/java/net/floodlightcontroller/core/internal/Controller.java
index b47962f..8c7c589 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/Controller.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/Controller.java
@@ -98,10 +98,9 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
 /**
- * The main controller class.  Handles all setup and network listeners
- * - Distributed ownership control of switch through IControllerRegistryService
+ * The main controller class. Handles all setup and network listeners -
+ * Distributed ownership control of switch through IControllerRegistryService
  */
 public class Controller implements IFloodlightProviderService {
 
@@ -126,8 +125,7 @@
     protected HashMap<String, String> controllerNodeIPsCache;
     protected BlockingQueue<IUpdate> updates;
 
-    protected ConcurrentMap<OFType,
-        ListenerDispatcher<OFType, IOFMessageListener>> messageListeners;
+    protected ConcurrentMap<OFType, ListenerDispatcher<OFType, IOFMessageListener>> messageListeners;
     protected Set<IOFSwitchListener> switchListeners;
 
     // Module dependencies
@@ -154,7 +152,7 @@
 
     // Load monitor for overload protection
     protected final boolean overload_drop =
-        Boolean.parseBoolean(System.getProperty("overload_drop", "false"));
+            Boolean.parseBoolean(System.getProperty("overload_drop", "false"));
     protected final LoadMonitor loadmonitor = new LoadMonitor(log);
 
     // Start time of the controller
@@ -168,35 +166,37 @@
     protected static final int BATCH_MAX_SIZE = 100;
     protected static final boolean ALWAYS_DECODE_ETH = true;
 
-
-
     // ******************************
     // Switch Management and Updates
     // ******************************
 
     /**
-     * Switch updates are sent to all IOFSwitchListeners. A switch that is connected
-     * to this controller instance, but not activated, is not available for updates.
-     *
-     * In ONOS, each controller instance can simultaneously serve in a MASTER role
-     * for some connected switches, and in a EQUAL role for other connected switches.
-     * The EQUAL role can be treated as a SLAVE role, by ensuring that the
-     * controller instance never sends packets or commands out to the switch.
-     * Activated switches, either with Controller Role MASTER or EQUAL are announced
-     * as updates. We also support announcements of controller role transitions
-     * from MASTER --> EQUAL, and EQUAL --> MASTER, for an individual switch.
-     *
+     * Switch updates are sent to all IOFSwitchListeners. A switch that is
+     * connected to this controller instance, but not activated, is not
+     * available for updates.
+     * 
+     * In ONOS, each controller instance can simultaneously serve in a MASTER
+     * role for some connected switches, and in a EQUAL role for other connected
+     * switches. The EQUAL role can be treated as a SLAVE role, by ensuring that
+     * the controller instance never sends packets or commands out to the
+     * switch. Activated switches, either with Controller Role MASTER or EQUAL
+     * are announced as updates. We also support announcements of controller
+     * role transitions from MASTER --> EQUAL, and EQUAL --> MASTER, for an
+     * individual switch.
+     * 
      * Disconnection of only activated switches are announced. Finally, changes
      * to switch ports are announced with a portChangeType (see @IOFSwitch)
-     *
+     * 
      * @author saurav
      */
     public enum SwitchUpdateType {
         /** switch activated with this controller's role as MASTER */
         ACTIVATED_MASTER,
-        /** switch activated with this controller's role as EQUAL.
-         *  listener can treat this controller's role as SLAVE by not
-         *  sending packets or commands to the switch */
+        /**
+         * switch activated with this controller's role as EQUAL. listener can
+         * treat this controller's role as SLAVE by not sending packets or
+         * commands to the switch
+         */
         ACTIVATED_EQUAL,
         /** this controller's role for this switch changed from Master to Equal */
         MASTER_TO_EQUAL,
@@ -209,8 +209,8 @@
     }
 
     /**
-     * Update message indicating a switch was added or removed
-     * ONOS: This message extended to indicate Port add or removed event.
+     * Update message indicating a switch was added or removed ONOS: This
+     * message extended to indicate Port add or removed event.
      */
     protected class SwitchUpdate implements IUpdate {
         public long getSwId() {
@@ -233,10 +233,11 @@
         public SwitchUpdate(long swId, SwitchUpdateType switchUpdateType) {
             this(swId, switchUpdateType, null, null);
         }
+
         public SwitchUpdate(long swId,
-                            SwitchUpdateType switchUpdateType,
-                            OFPortDesc port,
-                            PortChangeType changeType) {
+                SwitchUpdateType switchUpdateType,
+                OFPortDesc port,
+                PortChangeType changeType) {
             if (switchUpdateType == SwitchUpdateType.PORTCHANGED) {
                 if (port == null) {
                     throw new NullPointerException("Port must not be null " +
@@ -267,38 +268,37 @@
             }
             if (switchListeners != null) {
                 for (IOFSwitchListener listener : switchListeners) {
-                    switch(switchUpdateType) {
-                        case ACTIVATED_MASTER:
-                            // don't count here. We have more specific
-                            // counters before the update is created
-                            listener.switchActivatedMaster(swId);
-                            break;
-                        case ACTIVATED_EQUAL:
-                            // don't count here. We have more specific
-                            // counters before the update is created
-                            listener.switchActivatedEqual(swId);
-                            break;
-                        case MASTER_TO_EQUAL:
-                            listener.switchMasterToEqual(swId);
-                            break;
-                        case EQUAL_TO_MASTER:
-                            listener.switchEqualToMaster(swId);
-                            break;
-                        case DISCONNECTED:
-                            // don't count here. We have more specific
-                            // counters before the update is created
-                            listener.switchDisconnected(swId);
-                            break;
-                        case PORTCHANGED:
-                            counters.switchPortChanged.updateCounterWithFlush();
-                            listener.switchPortChanged(swId, port, changeType);
-                            break;
+                    switch (switchUpdateType) {
+                    case ACTIVATED_MASTER:
+                        // don't count here. We have more specific
+                        // counters before the update is created
+                        listener.switchActivatedMaster(swId);
+                        break;
+                    case ACTIVATED_EQUAL:
+                        // don't count here. We have more specific
+                        // counters before the update is created
+                        listener.switchActivatedEqual(swId);
+                        break;
+                    case MASTER_TO_EQUAL:
+                        listener.switchMasterToEqual(swId);
+                        break;
+                    case EQUAL_TO_MASTER:
+                        listener.switchEqualToMaster(swId);
+                        break;
+                    case DISCONNECTED:
+                        // don't count here. We have more specific
+                        // counters before the update is created
+                        listener.switchDisconnected(swId);
+                        break;
+                    case PORTCHANGED:
+                        counters.switchPortChanged.updateCounterWithFlush();
+                        listener.switchPortChanged(swId, port, changeType);
+                        break;
                     }
                 }
             }
         }
 
-
     }
 
     protected boolean addConnectedSwitch(long dpid, OFChannelHandler h) {
@@ -313,7 +313,7 @@
     }
 
     /**
-     *  Switch Events
+     * Switch Events
      */
     @Override
     public void addSwitchEvent(long dpid, String reason, boolean flushNow) {
@@ -335,9 +335,9 @@
             log.error("Trying to activate switch but it is already "
                     + "activated: dpid {}. Found in activeMaster: {} "
                     + "Found in activeEqual: {}. Aborting ..", new Object[] {
-                            HexString.toHexString(dpid),
-                            (activeMasterSwitches.get(dpid) == null)? 'Y': 'N',
-                            (activeEqualSwitches.get(dpid) == null)? 'Y': 'N'});
+                    HexString.toHexString(dpid),
+                    (activeMasterSwitches.get(dpid) == null) ? 'Y' : 'N',
+                    (activeEqualSwitches.get(dpid) == null) ? 'Y' : 'N'});
             counters.switchWithSameDpidActivated.updateCounterWithFlush();
             return false;
         }
@@ -348,8 +348,9 @@
      * Called when a switch is activated, with this controller's role as MASTER
      */
     protected boolean addActivatedMasterSwitch(long dpid, IOFSwitch sw) {
-        synchronized(multiCacheLock) {
-            if (!validActivation(dpid)) return false;
+        synchronized (multiCacheLock) {
+            if (!validActivation(dpid))
+                return false;
             activeMasterSwitches.put(dpid, sw);
         }
         // XXX Workaround to prevent race condition where a link is detected
@@ -360,7 +361,7 @@
             linkDiscovery.disableDiscoveryOnPort(sw.getId(),
                     port.getPortNo().getShortPortNumber());
         }
-        //update counters and events
+        // update counters and events
         counters.switchActivated.updateCounterWithFlush();
         evSwitch.updateEventWithFlush(new SwitchEvent(dpid, "activeMaster"));
         addUpdateToQueue(new SwitchUpdate(dpid,
@@ -372,11 +373,12 @@
      * Called when a switch is activated, with this controller's role as EQUAL
      */
     protected boolean addActivatedEqualSwitch(long dpid, IOFSwitch sw) {
-        synchronized(multiCacheLock) {
-            if (!validActivation(dpid)) return false;
+        synchronized (multiCacheLock) {
+            if (!validActivation(dpid))
+                return false;
             activeEqualSwitches.put(dpid, sw);
         }
-        //update counters and events
+        // update counters and events
         counters.switchActivated.updateCounterWithFlush();
         evSwitch.updateEventWithFlush(new SwitchEvent(dpid, "activeEqual"));
         addUpdateToQueue(new SwitchUpdate(dpid,
@@ -385,54 +387,54 @@
     }
 
     /**
-     * Called when this controller's role for a switch transitions from equal
-     * to master. For 1.0 switches, we internally refer to the role 'slave' as
+     * Called when this controller's role for a switch transitions from equal to
+     * master. For 1.0 switches, we internally refer to the role 'slave' as
      * 'equal' - so this transition is equivalent to 'addActivatedMasterSwitch'.
      */
     protected void transitionToMasterSwitch(long dpid) {
-	synchronized(multiCacheLock) {
-		IOFSwitch sw = activeEqualSwitches.remove(dpid);
-		if (sw == null) {
-			log.error("Transition to master called on sw {}, but switch "
-					+ "was not found in controller-cache", dpid);
-			return;
-		}
-		activeMasterSwitches.put(dpid, sw);
-	}
-	addUpdateToQueue(new SwitchUpdate(dpid,
+        synchronized (multiCacheLock) {
+            IOFSwitch sw = activeEqualSwitches.remove(dpid);
+            if (sw == null) {
+                log.error("Transition to master called on sw {}, but switch "
+                        + "was not found in controller-cache", dpid);
+                return;
+            }
+            activeMasterSwitches.put(dpid, sw);
+        }
+        addUpdateToQueue(new SwitchUpdate(dpid,
                 SwitchUpdateType.EQUAL_TO_MASTER));
     }
 
-
     /**
-     * Called when this controller's role for a switch transitions to equal.
-     * For 1.0 switches, we internally refer to the role 'slave' as
-     * 'equal'.
+     * Called when this controller's role for a switch transitions to equal. For
+     * 1.0 switches, we internally refer to the role 'slave' as 'equal'.
      */
     protected void transitionToEqualSwitch(long dpid) {
-	synchronized(multiCacheLock) {
-		IOFSwitch sw = activeMasterSwitches.remove(dpid);
-		if (sw == null) {
-			log.error("Transition to equal called on sw {}, but switch "
-					+ "was not found in controller-cache", dpid);
-			return;
-		}
-		activeEqualSwitches.put(dpid, sw);
-	}
-	addUpdateToQueue(new SwitchUpdate(dpid,
+        synchronized (multiCacheLock) {
+            IOFSwitch sw = activeMasterSwitches.remove(dpid);
+            if (sw == null) {
+                log.error("Transition to equal called on sw {}, but switch "
+                        + "was not found in controller-cache", dpid);
+                return;
+            }
+            activeEqualSwitches.put(dpid, sw);
+        }
+        addUpdateToQueue(new SwitchUpdate(dpid,
                 SwitchUpdateType.MASTER_TO_EQUAL));
     }
 
     /**
      * Clear all state in controller switch maps for a switch that has
-     * disconnected from the local controller. Also release control for
-     * that switch from the global repository. Notify switch listeners.
+     * disconnected from the local controller. Also release control for that
+     * switch from the global repository. Notify switch listeners.
      */
     protected void removeConnectedSwitch(long dpid) {
         releaseRegistryControl(dpid);
         connectedSwitches.remove(dpid);
         IOFSwitch sw = activeMasterSwitches.remove(dpid);
-        if (sw == null) sw = activeEqualSwitches.remove(dpid);
+        if (sw == null) {
+            sw = activeEqualSwitches.remove(dpid);
+        }
         if (sw != null) {
             sw.cancelAllStatisticsReplies();
             sw.setConnected(false); // do we need this?
@@ -443,8 +445,9 @@
     }
 
     /**
-     * Indicates that ports on the given switch have changed. Enqueue a
-     * switch update.
+     * Indicates that ports on the given switch have changed. Enqueue a switch
+     * update.
+     * 
      * @param sw
      */
     protected void notifyPortChanged(long dpid, OFPortDesc port,
@@ -465,7 +468,8 @@
             // and attempted to be written to the database before the port is in
             // the database. We now suppress link discovery on ports until we're
             // sure they're in the database.
-            linkDiscovery.disableDiscoveryOnPort(dpid, port.getPortNo().getShortPortNumber());
+            linkDiscovery.disableDiscoveryOnPort(dpid, port.getPortNo()
+                    .getShortPortNumber());
         }
 
         SwitchUpdate update = new SwitchUpdate(dpid, SwitchUpdateType.PORTCHANGED,
@@ -509,7 +513,8 @@
     // Role Handling
     // **********************
 
-    /** created by ONOS - works with registry service
+    /**
+     * created by ONOS - works with registry service
      */
     protected class RoleChangeCallback implements ControlChangeCallback {
         @Override
@@ -552,7 +557,7 @@
                     HexString.toHexString(dpid));
             // FIXME shouldn't we immediately return here?
         }
-        //Request control of the switch from the global registry
+        // Request control of the switch from the global registry
         try {
             h.controlRequested = Boolean.TRUE;
             registryService.requestControl(dpid, new RoleChangeCallback());
@@ -567,7 +572,8 @@
             } catch (InterruptedException e) {
                 // Ignore interruptions
             }
-            // safer to bounce the switch to reconnect here than proceeding further
+            // safer to bounce the switch to reconnect here than proceeding
+            // further
             // XXX S why? can't we just try again a little later?
             log.debug("Closing sw:{} because we weren't able to request control " +
                     "successfully" + dpid);
@@ -588,25 +594,24 @@
         }
     }
 
-
     // *******************
     // OF Message Handling
     // *******************
 
     /**
-     *
      * Handle and dispatch a message to IOFMessageListeners.
-     *
-     * We only dispatch messages to listeners if the controller's role is MASTER.
-     *
+     * 
+     * We only dispatch messages to listeners if the controller's role is
+     * MASTER.
+     * 
      * @param sw The switch sending the message
      * @param m The message the switch sent
-     * @param flContext The floodlight context to use for this message. If
-     * null, a new context will be allocated.
+     * @param flContext The floodlight context to use for this message. If null,
+     *        a new context will be allocated.
      * @throws IOException
-     *
-     * FIXME: this method and the ChannelHandler disagree on which messages
-     * should be dispatched and which shouldn't
+     * 
+     *         FIXME: this method and the ChannelHandler disagree on which
+     *         messages should be dispatched and which shouldn't
      */
     @LogMessageDocs({
             @LogMessageDoc(level = "ERROR",
@@ -620,114 +625,115 @@
                     explanation = "The switch sent a message not handled by " +
                             "the controller")
     })
-    @SuppressWarnings({ "fallthrough", "unchecked" })
+    @SuppressWarnings({"fallthrough", "unchecked"})
     protected void handleMessage(IOFSwitch sw, OFMessage m,
-                                 FloodlightContext bContext)
+            FloodlightContext bContext)
             throws IOException {
         Ethernet eth = null;
         short inport = -1;
 
         switch (m.getType()) {
-            case PACKET_IN:
-                OFPacketIn pi = (OFPacketIn) m;
-                //log.info("saw packet in from sw {}", sw.getStringId());
-                if (pi.getData().length <= 0) {
-                    log.error("Ignoring PacketIn (Xid = " + pi.getXid() +
-                            ") because/*  the data field is empty.");
+        case PACKET_IN:
+            OFPacketIn pi = (OFPacketIn) m;
+            // log.info("saw packet in from sw {}", sw.getStringId());
+            if (pi.getData().length <= 0) {
+                log.error("Ignoring PacketIn (Xid = " + pi.getXid() +
+                        ") because/*  the data field is empty.");
+                return;
+            }
+
+            // get incoming port to store in floodlight context
+            if (sw.getOFVersion() == OFVersion.OF_10) {
+                inport = pi.getInPort().getShortPortNumber();
+            } else if (sw.getOFVersion() == OFVersion.OF_13) {
+                for (MatchField<?> mf : pi.getMatch().getMatchFields()) {
+                    if (mf.id == MatchFields.IN_PORT) {
+                        inport = pi.getMatch().get((MatchField<OFPort>) mf)
+                                .getShortPortNumber();
+                        break;
+                    }
+                }
+                if (inport == -1) {
+                    log.error("Match field for incoming port missing in "
+                            + "packet-in from sw {}. Ignoring msg",
+                            sw.getStringId());
                     return;
                 }
+            } else {
+                // should have been taken care of earlier in handshake
+                log.error("OFVersion {} not supported for "
+                        + "packet-in from sw {}. Ignoring msg",
+                        sw.getOFVersion(), sw.getStringId());
+                return;
+            }
 
-                // get incoming port to store in floodlight context
-                if (sw.getOFVersion() == OFVersion.OF_10) {
-                    inport = pi.getInPort().getShortPortNumber();
-                } else if (sw.getOFVersion() == OFVersion.OF_13) {
-                    for (MatchField<?> mf : pi.getMatch().getMatchFields()) {
-                        if (mf.id == MatchFields.IN_PORT) {
-                            inport = pi.getMatch().get((MatchField<OFPort>)mf)
-                                        .getShortPortNumber();
-                            break;
-                        }
-                    }
-                    if (inport == -1) {
-                        log.error("Match field for incoming port missing in "
-                                + "packet-in from sw {} .. Ignoring msg",
-                                sw.getStringId());
-                        return;
-                    }
+            // decode enclosed ethernet packet to store in floodlight context
+            if (Controller.ALWAYS_DECODE_ETH) {
+                eth = new Ethernet();
+                eth.deserialize(pi.getData(), 0,
+                        pi.getData().length);
+            }
+            // fall through to default case...
+
+            /*log.debug("Sw:{} packet-in: {}", sw.getStringId(),
+            String.format("0x%x", eth.getEtherType()));*/
+            if (eth.getEtherType() != (short) EthType.LLDP.getValue())
+                log.trace("Sw:{} packet-in: {}", sw.getStringId(), pi);
+
+        default:
+
+            List<IOFMessageListener> listeners = null;
+
+            if (messageListeners.containsKey(m.getType())) {
+                listeners = messageListeners.get(m.getType()).
+                        getOrderedListeners();
+            }
+            FloodlightContext bc = null;
+            if (listeners != null) {
+                // Check if floodlight context is passed from the calling
+                // function, if so use that floodlight context, otherwise
+                // allocate one
+                if (bContext == null) {
+                    bc = flcontext_alloc();
                 } else {
-                    // should have been taken care of earlier in handshake
-                    log.error("OFVersion {} not supported for "
-                            + "packet-in from sw {} .. Ignoring msg",
-                            sw.getOFVersion(), sw.getStringId());
-                    return;
+                    bc = bContext;
+                }
+                if (eth != null) {
+                    IFloodlightProviderService.bcStore.put(bc,
+                            IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
+                            eth);
+                }
+                if (inport != -1) {
+                    bc.getStorage().put(
+                            IFloodlightProviderService.CONTEXT_PI_INPORT,
+                            inport);
                 }
 
-                // decode enclosed ethernet packet to store in floodlight context
-                if (Controller.ALWAYS_DECODE_ETH) {
-                    eth = new Ethernet();
-                    eth.deserialize(pi.getData(), 0,
-                            pi.getData().length);
-                }
-                // fall through to default case...
+                // Get the starting time (overall and per-component) of
+                // the processing chain for this packet if performance
+                // monitoring is turned on
 
-                /*log.debug("Sw:{} packet-in: {}", sw.getStringId(),
-				String.format("0x%x", eth.getEtherType()));*/
-                if (eth.getEtherType() != (short)EthType.LLDP.getValue())
-			log.trace("Sw:{} packet-in: {}", sw.getStringId(), pi);
-
-            default:
-
-                List<IOFMessageListener> listeners = null;
-
-                if (messageListeners.containsKey(m.getType())) {
-                    listeners = messageListeners.get(m.getType()).
-                            getOrderedListeners();
-                }
-                FloodlightContext bc = null;
-                if (listeners != null) {
-                    // Check if floodlight context is passed from the calling
-                    // function, if so use that floodlight context, otherwise
-                    // allocate one
-                    if (bContext == null) {
-                        bc = flcontext_alloc();
-                    } else {
-                        bc = bContext;
-                    }
-                    if (eth != null) {
-                        IFloodlightProviderService.bcStore.put(bc,
-                                IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
-                                eth);
-                    }
-                    if (inport != -1) {
-                        bc.getStorage().put(
-                                IFloodlightProviderService.CONTEXT_PI_INPORT,
-                                inport);
-                    }
-
-                    // Get the starting time (overall and per-component) of
-                    // the processing chain for this packet if performance
-                    // monitoring is turned on
-
-                    Command cmd = null;
-                    for (IOFMessageListener listener : listeners) {
-                        if (listener instanceof IOFSwitchFilter) {
-                            if (!((IOFSwitchFilter) listener).isInterested(sw)) {
-                                continue;
-                            }
-                        }
-
-                        cmd = listener.receive(sw, m, bc);
-
-                        if (Command.STOP.equals(cmd)) {
-                            break;
+                Command cmd = null;
+                for (IOFMessageListener listener : listeners) {
+                    if (listener instanceof IOFSwitchFilter) {
+                        if (!((IOFSwitchFilter) listener).isInterested(sw)) {
+                            continue;
                         }
                     }
 
-                } else {
-                    log.warn("Unhandled OF Message: {} from {}", m, sw);
+                    cmd = listener.receive(sw, m, bc);
+
+                    if (Command.STOP.equals(cmd)) {
+                        break;
+                    }
                 }
 
-                if ((bContext == null) && (bc != null)) flcontext_free(bc);
+            } else {
+                log.warn("Unhandled OF Message: {} from {}", m, sw);
+            }
+
+            if ((bContext == null) && (bc != null))
+                flcontext_free(bc);
         }
     }
 
@@ -737,7 +743,7 @@
 
     // FIXME: remove this method
     @Override
-    public Map<Long,IOFSwitch> getSwitches() {
+    public Map<Long, IOFSwitch> getSwitches() {
         return getMasterSwitches();
     }
 
@@ -746,7 +752,6 @@
         return Collections.unmodifiableMap(activeMasterSwitches);
     }
 
-
     @Override
     public Set<Long> getAllSwitchDpids() {
         Set<Long> dpids = new HashSet<Long>();
@@ -772,24 +777,26 @@
     @Override
     public IOFSwitch getSwitch(long dpid) {
         IOFSwitch sw = null;
-        if ((sw = activeMasterSwitches.get(dpid)) != null) return sw;
-        if ((sw = activeEqualSwitches.get(dpid)) != null) return sw;
+        if ((sw = activeMasterSwitches.get(dpid)) != null)
+            return sw;
+        if ((sw = activeEqualSwitches.get(dpid)) != null)
+            return sw;
         return sw;
     }
 
     @Override
     public IOFSwitch getMasterSwitch(long dpid) {
-        return  activeMasterSwitches.get(dpid);
+        return activeMasterSwitches.get(dpid);
     }
 
     @Override
     public IOFSwitch getEqualSwitch(long dpid) {
-        return  activeEqualSwitches.get(dpid);
+        return activeEqualSwitches.get(dpid);
     }
 
     @Override
     public synchronized void addOFMessageListener(OFType type,
-                                                  IOFMessageListener listener) {
+            IOFMessageListener listener) {
         ListenerDispatcher<OFType, IOFMessageListener> ldd =
                 messageListeners.get(type);
         if (ldd == null) {
@@ -801,7 +808,7 @@
 
     @Override
     public synchronized void removeOFMessageListener(OFType type,
-                                                     IOFMessageListener listener) {
+            IOFMessageListener listener) {
         ListenerDispatcher<OFType, IOFMessageListener> ldd =
                 messageListeners.get(type);
         if (ldd != null) {
@@ -814,10 +821,8 @@
     }
 
     private void logListeners() {
-        for (Map.Entry<OFType,
-                ListenerDispatcher<OFType,
-                        IOFMessageListener>> entry
-                : messageListeners.entrySet()) {
+        for (Map.Entry<OFType, ListenerDispatcher<OFType, IOFMessageListener>> entry : messageListeners
+                .entrySet()) {
 
             OFType type = entry.getKey();
             ListenerDispatcher<OFType, IOFMessageListener> ldd =
@@ -857,8 +862,8 @@
     public Map<OFType, List<IOFMessageListener>> getListeners() {
         Map<OFType, List<IOFMessageListener>> lers =
                 new HashMap<OFType, List<IOFMessageListener>>();
-        for (Entry<OFType, ListenerDispatcher<OFType, IOFMessageListener>> e :
-                messageListeners.entrySet()) {
+        for (Entry<OFType, ListenerDispatcher<OFType, IOFMessageListener>> e : messageListeners
+                .entrySet()) {
             lers.put(e.getKey(), e.getValue().getOrderedListeners());
         }
         return Collections.unmodifiableMap(lers);
@@ -905,42 +910,39 @@
         return true;
     }*/
 
+    // @Override
+    // public boolean injectOfMessage(IOFSwitch sw, OFMessage msg) {
+    // // call the overloaded version with floodlight context set to null
+    // return injectOfMessage(sw, msg, null);
+    // }
 
-
-//    @Override
-//    public boolean injectOfMessage(IOFSwitch sw, OFMessage msg) {
-//        // call the overloaded version with floodlight context set to null
-//        return injectOfMessage(sw, msg, null);
-//    }
-
-//    @Override
-//    public void handleOutgoingMessage(IOFSwitch sw, OFMessage m,
-//                                      FloodlightContext bc) {
-//
-//        List<IOFMessageListener> listeners = null;
-//        if (messageListeners.containsKey(m.getType())) {
-//            listeners =
-//                    messageListeners.get(m.getType()).getOrderedListeners();
-//        }
-//
-//        if (listeners != null) {
-//            for (IOFMessageListener listener : listeners) {
-//                if (listener instanceof IOFSwitchFilter) {
-//                    if (!((IOFSwitchFilter) listener).isInterested(sw)) {
-//                        continue;
-//                    }
-//                }
-//                if (Command.STOP.equals(listener.receive(sw, m, bc))) {
-//                    break;
-//                }
-//            }
-//        }
-//    }
-
+    // @Override
+    // public void handleOutgoingMessage(IOFSwitch sw, OFMessage m,
+    // FloodlightContext bc) {
+    //
+    // List<IOFMessageListener> listeners = null;
+    // if (messageListeners.containsKey(m.getType())) {
+    // listeners =
+    // messageListeners.get(m.getType()).getOrderedListeners();
+    // }
+    //
+    // if (listeners != null) {
+    // for (IOFMessageListener listener : listeners) {
+    // if (listener instanceof IOFSwitchFilter) {
+    // if (!((IOFSwitchFilter) listener).isInterested(sw)) {
+    // continue;
+    // }
+    // }
+    // if (Command.STOP.equals(listener.receive(sw, m, bc))) {
+    // break;
+    // }
+    // }
+    // }
+    // }
 
     /**
      * Gets an OpenFlow message factory for version 1.0.
-     *
+     * 
      * @return an OpenFlow 1.0 message factory
      */
     public OFFactory getOFMessageFactory_10() {
@@ -949,7 +951,7 @@
 
     /**
      * Gets an OpenFlow message factory for version 1.3.
-     *
+     * 
      * @return an OpenFlow 1.3 message factory
      */
     public OFFactory getOFMessageFactory_13() {
@@ -1004,7 +1006,6 @@
         }
     }
 
-
     // **************
     // Initialization
     // **************
@@ -1013,25 +1014,24 @@
     // controller roles per switch! Then it could be a way to
     // deterministically configure a switch to a MASTER controller instance
     /**
-     * Sets the initial role based on properties in the config params.
-     * It looks for two different properties.
-     * If the "role" property is specified then the value should be
-     * either "EQUAL", "MASTER", or "SLAVE" and the role of the
-     * controller is set to the specified value. If the "role" property
-     * is not specified then it looks next for the "role.path" property.
-     * In this case the value should be the path to a property file in
-     * the file system that contains a property called "floodlight.role"
-     * which can be one of the values listed above for the "role" property.
-     * The idea behind the "role.path" mechanism is that you have some
-     * separate heartbeat and master controller election algorithm that
-     * determines the role of the controller. When a role transition happens,
-     * it updates the current role in the file specified by the "role.path"
-     * file. Then if floodlight restarts for some reason it can get the
-     * correct current role of the controller from the file.
-     *
+     * Sets the initial role based on properties in the config params. It looks
+     * for two different properties. If the "role" property is specified then
+     * the value should be either "EQUAL", "MASTER", or "SLAVE" and the role of
+     * the controller is set to the specified value. If the "role" property is
+     * not specified then it looks next for the "role.path" property. In this
+     * case the value should be the path to a property file in the file system
+     * that contains a property called "floodlight.role" which can be one of the
+     * values listed above for the "role" property. The idea behind the
+     * "role.path" mechanism is that you have some separate heartbeat and master
+     * controller election algorithm that determines the role of the controller.
+     * When a role transition happens, it updates the current role in the file
+     * specified by the "role.path" file. Then if floodlight restarts for some
+     * reason it can get the correct current role of the controller from the
+     * file.
+     * 
      * @param configParams The config params for the FloodlightProvider service
-     * @return A valid role if role information is specified in the
-     * config params, otherwise null
+     * @return A valid role if role information is specified in the config
+     *         params, otherwise null
      */
     @LogMessageDocs({
             @LogMessageDoc(message = "Controller role set to {role}",
@@ -1089,7 +1089,7 @@
 
     /**
      * Tell controller that we're ready to accept switches loop
-     *
+     * 
      * @throws IOException
      */
     @Override
@@ -1138,7 +1138,7 @@
                 update.dispatch();
             } catch (InterruptedException e) {
                 log.error("Received interrupted exception in updates loop;" +
-                          "terminating process");
+                        "terminating process");
                 terminate();
             } catch (Exception e) {
                 log.error("Exception in controller updates loop", e);
@@ -1175,7 +1175,8 @@
         if (controllerId != null) {
             this.onosInstanceId = new OnosInstanceId(controllerId);
         } else {
-            //Try to get the hostname of the machine and use that for controller ID
+            // Try to get the hostname of the machine and use that for
+            // controller ID
             try {
                 String hostname = java.net.InetAddress.getLocalHost().getHostName();
                 this.onosInstanceId = new OnosInstanceId(hostname);
@@ -1187,7 +1188,6 @@
         log.debug("ControllerId set to {}", this.onosInstanceId);
     }
 
-
     /**
      * Initialize internal data structures
      */
@@ -1196,7 +1196,7 @@
         // module's startUp() might be called before ours
         this.messageListeners =
                 new ConcurrentHashMap<OFType, ListenerDispatcher<OFType,
-                                                    IOFMessageListener>>();
+                IOFMessageListener>>();
         this.switchListeners = new CopyOnWriteArraySet<IOFSwitchListener>();
         this.activeMasterSwitches = new ConcurrentHashMap<Long, IOFSwitch>();
         this.activeEqualSwitches = new ConcurrentHashMap<Long, IOFSwitch>();
@@ -1221,6 +1221,7 @@
 
     /**
      * Startup all of the controller's components
+     * 
      * @throws FloodlightModuleException
      */
     @LogMessageDoc(message = "Waiting for storage source",
@@ -1241,7 +1242,7 @@
         // Startup load monitoring
         if (overload_drop) {
             this.loadmonitor.startMonitoring(
-                this.threadPool.getScheduledExecutor());
+                    this.threadPool.getScheduledExecutor());
         }
 
         // register counters and events
@@ -1270,7 +1271,7 @@
         public IDebugCounter switchActivated;
         public IDebugCounter errorSameSwitchReactivated; // err
         public IDebugCounter switchWithSameDpidActivated; // warn
-        public IDebugCounter newSwitchActivated;   // new switch
+        public IDebugCounter newSwitchActivated; // new switch
         public IDebugCounter syncedSwitchActivated;
         public IDebugCounter readyForReconcile;
         public IDebugCounter newSwitchFromStore;
@@ -1285,7 +1286,9 @@
         public IDebugCounter switchPortChanged;
         public IDebugCounter switchOtherChange;
         public IDebugCounter dispatchMessageWhileSlave;
-        public IDebugCounter dispatchMessage;  // does this cnt make sense? more specific?? per type? count stops?
+        public IDebugCounter dispatchMessage; // does this cnt make sense? more
+                                              // specific?? per type? count
+                                              // stops?
         public IDebugCounter controllerNodeIpsChanged;
         public IDebugCounter messageReceived;
         public IDebugCounter messageInputThrottled;
@@ -1310,400 +1313,402 @@
 
         void createCounters(IDebugCounterService debugCounters) throws CounterException {
             setRoleEqual =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "set-role-equal",
-                            "Controller received a role request with role of "+
-                            "EQUAL which is unusual",
+                            "Controller received a role request with role of " +
+                                    "EQUAL which is unusual",
                             CounterType.ALWAYS_COUNT);
             setSameRole =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "set-same-role",
                             "Controller received a role request for the same " +
-                            "role the controller already had",
+                                    "role the controller already had",
                             CounterType.ALWAYS_COUNT,
                             IDebugCounterService.CTR_MDATA_WARN);
 
             setRoleMaster =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "set-role-master",
                             "Controller received a role request with role of " +
-                            "MASTER. This counter can be at most 1.",
+                                    "MASTER. This counter can be at most 1.",
                             CounterType.ALWAYS_COUNT);
 
             remoteStoreNotification =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "remote-store-notification",
                             "Received a notification from the sync service " +
-                            "indicating that switch information has changed",
+                                    "indicating that switch information has changed",
                             CounterType.ALWAYS_COUNT);
 
             invalidPortsChanged =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "invalid-ports-changed",
                             "Received an unexpected ports changed " +
-                            "notification while the controller was in " +
-                            "SLAVE role.",
+                                    "notification while the controller was in " +
+                                    "SLAVE role.",
                             CounterType.ALWAYS_COUNT,
                             IDebugCounterService.CTR_MDATA_WARN);
 
             invalidSwitchActivatedWhileSlave =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "invalid-switch-activated-while-slave",
                             "Received an unexpected switchActivated " +
-                            "notification while the controller was in " +
-                            "SLAVE role.",
+                                    "notification while the controller was in " +
+                                    "SLAVE role.",
                             CounterType.ALWAYS_COUNT,
                             IDebugCounterService.CTR_MDATA_WARN);
 
             invalidStoreEventWhileMaster =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "invalid-store-event-while-master",
                             "Received an unexpected notification from " +
-                            "the sync store while the controller was in " +
-                            "MASTER role.",
+                                    "the sync store while the controller was in " +
+                                    "MASTER role.",
                             CounterType.ALWAYS_COUNT,
                             IDebugCounterService.CTR_MDATA_WARN);
 
             switchDisconnectedWhileSlave =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "switch-disconnected-while-slave",
                             "A switch disconnected and the controller was " +
-                            "in SLAVE role.",
+                                    "in SLAVE role.",
                             CounterType.ALWAYS_COUNT,
                             IDebugCounterService.CTR_MDATA_WARN);
 
             switchActivated =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "switch-activated",
                             "A switch connected to this controller is now " +
-                            "in MASTER role",
+                                    "in MASTER role",
                             CounterType.ALWAYS_COUNT);
 
             errorSameSwitchReactivated = // err
-                debugCounters.registerCounter(
-                            prefix, "error-same-switch-reactivated",
-                            "A switch that was already in active state " +
+            debugCounters.registerCounter(
+                    prefix, "error-same-switch-reactivated",
+                    "A switch that was already in active state " +
                             "was activated again. This indicates a " +
                             "controller defect",
-                            CounterType.ALWAYS_COUNT,
-                            IDebugCounterService.CTR_MDATA_ERROR);
+                    CounterType.ALWAYS_COUNT,
+                    IDebugCounterService.CTR_MDATA_ERROR);
 
             switchWithSameDpidActivated = // warn
-                debugCounters.registerCounter(
-                            prefix, "switch-with-same-dpid-activated",
-                            "A switch with the same DPID as another switch " +
+            debugCounters.registerCounter(
+                    prefix, "switch-with-same-dpid-activated",
+                    "A switch with the same DPID as another switch " +
                             "connected to the controller. This can be " +
                             "caused by multiple switches configured with " +
                             "the same DPID or by a switch reconnecting very " +
                             "quickly.",
-                            CounterType.COUNT_ON_DEMAND,
-                            IDebugCounterService.CTR_MDATA_WARN);
+                    CounterType.COUNT_ON_DEMAND,
+                    IDebugCounterService.CTR_MDATA_WARN);
 
-            newSwitchActivated =   // new switch
-                debugCounters.registerCounter(
-                            prefix, "new-switch-activated",
-                            "A new switch has completed the handshake as " +
+            newSwitchActivated = // new switch
+            debugCounters.registerCounter(
+                    prefix, "new-switch-activated",
+                    "A new switch has completed the handshake as " +
                             "MASTER. The switch was not known to any other " +
                             "controller in the cluster",
-                            CounterType.ALWAYS_COUNT);
+                    CounterType.ALWAYS_COUNT);
             syncedSwitchActivated =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "synced-switch-activated",
                             "A switch has completed the handshake as " +
-                            "MASTER. The switch was known to another " +
-                            "controller in the cluster",
+                                    "MASTER. The switch was known to another " +
+                                    "controller in the cluster",
                             CounterType.ALWAYS_COUNT);
 
             readyForReconcile =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "ready-for-reconcile",
                             "Controller is ready for flow reconciliation " +
-                            "after Slave to Master transition. Either all " +
-                            "previously known switches are now active " +
-                            "or they have timed out and have been removed." +
-                            "This counter will be 0 or 1.",
+                                    "after Slave to Master transition. Either all " +
+                                    "previously known switches are now active " +
+                                    "or they have timed out and have been removed." +
+                                    "This counter will be 0 or 1.",
                             CounterType.ALWAYS_COUNT);
 
             newSwitchFromStore =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "new-switch-from-store",
                             "A new switch has connected to another " +
-                            "another controller in the cluster. This " +
-                            "controller instance has received a sync store " +
-                            "notification for it.",
+                                    "another controller in the cluster. This " +
+                                    "controller instance has received a sync store " +
+                                    "notification for it.",
                             CounterType.ALWAYS_COUNT);
 
             updatedSwitchFromStore =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "updated-switch-from-store",
                             "Information about a switch connected to " +
-                            "another controller instance was updated in " +
-                            "the sync store. This controller instance has " +
-                            "received a notification for it",
+                                    "another controller instance was updated in " +
+                                    "the sync store. This controller instance has " +
+                                    "received a notification for it",
                             CounterType.ALWAYS_COUNT);
 
             switchDisconnected =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "switch-disconnected",
                             "FIXME: switch has disconnected",
                             CounterType.ALWAYS_COUNT);
 
             syncedSwitchRemoved =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "synced-switch-removed",
                             "A switch connected to another controller " +
-                            "instance has disconnected from the controller " +
-                            "cluster. This controller instance has " +
-                            "received a notification for it",
+                                    "instance has disconnected from the controller " +
+                                    "cluster. This controller instance has " +
+                                    "received a notification for it",
                             CounterType.ALWAYS_COUNT);
 
             unknownSwitchRemovedFromStore =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "unknown-switch-removed-from-store",
                             "This controller instances has received a sync " +
-                            "store notification that a switch has " +
-                            "disconnected but this controller instance " +
-                            "did not have the any information about the " +
-                            "switch", // might be less than warning
+                                    "store notification that a switch has " +
+                                    "disconnected but this controller instance " +
+                                    "did not have the any information about the " +
+                                    "switch", // might be less than warning
                             CounterType.ALWAYS_COUNT,
                             IDebugCounterService.CTR_MDATA_WARN);
 
             consolidateStoreRunCount =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "consolidate-store-run-count",
                             "This controller has transitioned from SLAVE " +
-                            "to MASTER and waited for switches to reconnect. " +
-                            "The controller has finished waiting and has " +
-                            "reconciled switch entries in the sync store " +
-                            "with live state",
+                                    "to MASTER and waited for switches to reconnect. " +
+                                    "The controller has finished waiting and has " +
+                                    "reconciled switch entries in the sync store " +
+                                    "with live state",
                             CounterType.ALWAYS_COUNT);
 
             consolidateStoreInconsistencies =
                     debugCounters.registerCounter(
-                                prefix, "consolidate-store-inconsistencies",
-                                "During switch sync store consolidation: " +
-                                "Number of switches that were in the store " +
-                                "but not otherwise known plus number of " +
-                                "switches that were in the store previously " +
-                                "but are now missing plus number of "  +
-                                "connected switches that were absent from " +
-                                "the store although this controller has " +
-                                "written them. A non-zero count " +
-                                "indicates a brief split-brain dual MASTER " +
-                                "situation during fail-over",
-                                CounterType.ALWAYS_COUNT);
+                            prefix, "consolidate-store-inconsistencies",
+                            "During switch sync store consolidation: " +
+                                    "Number of switches that were in the store " +
+                                    "but not otherwise known plus number of " +
+                                    "switches that were in the store previously " +
+                                    "but are now missing plus number of " +
+                                    "connected switches that were absent from " +
+                                    "the store although this controller has " +
+                                    "written them. A non-zero count " +
+                                    "indicates a brief split-brain dual MASTER " +
+                                    "situation during fail-over",
+                            CounterType.ALWAYS_COUNT);
 
             storeSyncError =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "store-sync-error",
                             "Number of times a sync store operation failed " +
-                            "due to a store sync exception or an entry in " +
-                            "in the store had invalid data.",
+                                    "due to a store sync exception or an entry in " +
+                                    "in the store had invalid data.",
                             CounterType.ALWAYS_COUNT,
                             IDebugCounterService.CTR_MDATA_ERROR);
 
             switchesNotReconnectingToNewMaster =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "switches-not-reconnecting-to-new-master",
                             "Switches that were connected to another " +
-                            "controller instance in the cluster but that " +
-                            "did not reconnect to this controller after it " +
-                            "transitioned to MASTER", // might be less than warning
+                                    "controller instance in the cluster but that " +
+                                    "did not reconnect to this controller after it " +
+                                    "transitioned to MASTER", // might be less
+                                                              // than warning
                             CounterType.ALWAYS_COUNT);
 
             switchPortChanged =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "switch-port-changed",
                             "Number of times switch ports have changed",
                             CounterType.ALWAYS_COUNT);
             switchOtherChange =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "switch-other-change",
                             "Number of times other information of a switch " +
-                            "has changed.",
+                                    "has changed.",
                             CounterType.ALWAYS_COUNT);
 
             dispatchMessageWhileSlave =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "dispatch-message-while-slave",
                             "Number of times an OF message was received " +
-                            "and supposed to be dispatched but the " +
-                            "controller was in SLAVE role and the message " +
-                            "was not dispatched",
+                                    "and supposed to be dispatched but the " +
+                                    "controller was in SLAVE role and the message " +
+                                    "was not dispatched",
                             CounterType.ALWAYS_COUNT);
 
-            dispatchMessage =  // does this cnt make sense? more specific?? per type? count stops?
-                debugCounters.registerCounter(
-                            prefix, "dispatch-message",
-                            "Number of times an OF message was dispatched " +
+            dispatchMessage = // does this cnt make sense? more specific?? per
+                              // type? count stops?
+            debugCounters.registerCounter(
+                    prefix, "dispatch-message",
+                    "Number of times an OF message was dispatched " +
                             "to registered modules",
-                            CounterType.ALWAYS_COUNT);
+                    CounterType.ALWAYS_COUNT);
 
             controllerNodeIpsChanged =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "controller-nodes-ips-changed",
                             "IP addresses of controller nodes have changed",
                             CounterType.ALWAYS_COUNT);
 
-        //------------------------
-        // channel handler counters. Factor them out ??
+            // ------------------------
+            // channel handler counters. Factor them out ??
             messageReceived =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "message-received",
                             "Number of OpenFlow messages received. Some of " +
-                            "these might be throttled",
+                                    "these might be throttled",
                             CounterType.ALWAYS_COUNT);
             messageInputThrottled =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "message-input-throttled",
                             "Number of OpenFlow messages that were " +
-                            "throttled due to high load from the sender",
+                                    "throttled due to high load from the sender",
                             CounterType.ALWAYS_COUNT,
                             IDebugCounterService.CTR_MDATA_WARN);
-        // TODO: more counters in messageReceived ??
+            // TODO: more counters in messageReceived ??
 
             switchDisconnectReadTimeout =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "switch-disconnect-read-timeout",
                             "Number of times a switch was disconnected due " +
-                            "due the switch failing to send OpenFlow " +
-                            "messages or responding to OpenFlow ECHOs",
+                                    "due the switch failing to send OpenFlow " +
+                                    "messages or responding to OpenFlow ECHOs",
                             CounterType.ALWAYS_COUNT,
                             IDebugCounterService.CTR_MDATA_ERROR);
             switchDisconnectHandshakeTimeout =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "switch-disconnect-handshake-timeout",
                             "Number of times a switch was disconnected " +
-                            "because it failed to complete the handshake " +
-                            "in time.",
+                                    "because it failed to complete the handshake " +
+                                    "in time.",
                             CounterType.ALWAYS_COUNT,
                             IDebugCounterService.CTR_MDATA_ERROR);
             switchDisconnectIOError =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "switch-disconnect-io-error",
                             "Number of times a switch was disconnected " +
-                            "due to IO errors on the switch connection.",
+                                    "due to IO errors on the switch connection.",
                             CounterType.ALWAYS_COUNT,
                             IDebugCounterService.CTR_MDATA_ERROR);
             switchDisconnectParseError =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "switch-disconnect-parse-error",
-                           "Number of times a switch was disconnected " +
-                           "because it sent an invalid packet that could " +
-                           "not be parsed",
-                           CounterType.ALWAYS_COUNT,
-                           IDebugCounterService.CTR_MDATA_ERROR);
+                            "Number of times a switch was disconnected " +
+                                    "because it sent an invalid packet that could " +
+                                    "not be parsed",
+                            CounterType.ALWAYS_COUNT,
+                            IDebugCounterService.CTR_MDATA_ERROR);
 
             switchDisconnectSwitchStateException =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "switch-disconnect-switch-state-exception",
                             "Number of times a switch was disconnected " +
-                            "because it sent messages that were invalid " +
-                            "given the switch connection's state.",
+                                    "because it sent messages that were invalid " +
+                                    "given the switch connection's state.",
                             CounterType.ALWAYS_COUNT,
                             IDebugCounterService.CTR_MDATA_ERROR);
             rejectedExecutionException =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "rejected-execution-exception",
                             "TODO",
                             CounterType.ALWAYS_COUNT,
                             IDebugCounterService.CTR_MDATA_ERROR);
 
             switchDisconnectOtherException =
-                debugCounters.registerCounter(
-                            prefix,  "switch-disconnect-other-exception",
+                    debugCounters.registerCounter(
+                            prefix, "switch-disconnect-other-exception",
                             "Number of times a switch was disconnected " +
-                            "due to an exceptional situation not covered " +
-                            "by other counters",
+                                    "due to an exceptional situation not covered " +
+                                    "by other counters",
                             CounterType.ALWAYS_COUNT,
                             IDebugCounterService.CTR_MDATA_ERROR);
 
             switchConnected =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "switch-connected",
                             "Number of times a new switch connection was " +
-                            "established",
+                                    "established",
                             CounterType.ALWAYS_COUNT);
 
             unhandledMessage =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "unhandled-message",
                             "Number of times an OpenFlow message was " +
-                            "received that the controller ignored because " +
-                            "it was inapproriate given the switch " +
-                            "connection's state.",
+                                    "received that the controller ignored because " +
+                                    "it was inapproriate given the switch " +
+                                    "connection's state.",
                             CounterType.ALWAYS_COUNT,
                             IDebugCounterService.CTR_MDATA_WARN);
-                            // might be less than warning
+            // might be less than warning
 
             packetInWhileSwitchIsSlave =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "packet-in-while-switch-is-slave",
                             "Number of times a packet in was received " +
-                            "from a switch that was in SLAVE role. " +
-                            "Possibly inidicates inconsistent roles.",
+                                    "from a switch that was in SLAVE role. " +
+                                    "Possibly inidicates inconsistent roles.",
                             CounterType.ALWAYS_COUNT);
             epermErrorWhileSwitchIsMaster =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "eperm-error-while-switch-is-master",
                             "Number of times a permission error was " +
-                            "received while the switch was in MASTER role. " +
-                            "Possibly inidicates inconsistent roles.",
+                                    "received while the switch was in MASTER role. " +
+                                    "Possibly inidicates inconsistent roles.",
                             CounterType.ALWAYS_COUNT,
                             IDebugCounterService.CTR_MDATA_WARN);
 
             roleNotResentBecauseRolePending =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "role-not-resent-because-role-pending",
                             "The controller tried to reestablish a role " +
-                            "with a switch but did not do so because a " +
-                            "previous role request was still pending",
+                                    "with a switch but did not do so because a " +
+                                    "previous role request was still pending",
                             CounterType.ALWAYS_COUNT);
             roleRequestSent =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "role-request-sent",
                             "Number of times the controller sent a role " +
-                            "request to a switch.",
+                                    "request to a switch.",
                             CounterType.ALWAYS_COUNT);
             roleReplyTimeout =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "role-reply-timeout",
                             "Number of times a role request message did not " +
-                            "receive the expected reply from a switch",
+                                    "receive the expected reply from a switch",
                             CounterType.ALWAYS_COUNT,
                             IDebugCounterService.CTR_MDATA_WARN);
 
             roleReplyReceived = // expected RoleReply received
-                debugCounters.registerCounter(
-                            prefix, "role-reply-received",
-                            "Number of times the controller received the " +
+            debugCounters.registerCounter(
+                    prefix, "role-reply-received",
+                    "Number of times the controller received the " +
                             "expected role reply message from a switch",
-                            CounterType.ALWAYS_COUNT);
+                    CounterType.ALWAYS_COUNT);
 
             roleReplyErrorUnsupported =
-                debugCounters.registerCounter(
+                    debugCounters.registerCounter(
                             prefix, "role-reply-error-unsupported",
                             "Number of times the controller received an " +
-                            "error from a switch in response to a role " +
-                            "request indicating that the switch does not " +
-                            "support roles.",
+                                    "error from a switch in response to a role " +
+                                    "request indicating that the switch does not " +
+                                    "support roles.",
                             CounterType.ALWAYS_COUNT);
 
             switchCounterRegistrationFailed =
                     debugCounters.registerCounter(prefix,
-                                "switch-counter-registration-failed",
-                                "Number of times the controller failed to " +
-                                "register per-switch debug counters",
-                                CounterType.ALWAYS_COUNT,
-                                IDebugCounterService.CTR_MDATA_WARN);
+                            "switch-counter-registration-failed",
+                            "Number of times the controller failed to " +
+                                    "register per-switch debug counters",
+                            CounterType.ALWAYS_COUNT,
+                            IDebugCounterService.CTR_MDATA_WARN);
 
             packetParsingError =
                     debugCounters.registerCounter(prefix,
-                                "packet-parsing-error",
-                                "Number of times the packet parsing " +
-                                "encountered an error",
-                                CounterType.ALWAYS_COUNT,
-                                IDebugCounterService.CTR_MDATA_ERROR);
+                            "packet-parsing-error",
+                            "Number of times the packet parsing " +
+                                    "encountered an error",
+                            CounterType.ALWAYS_COUNT,
+                            IDebugCounterService.CTR_MDATA_ERROR);
         }
     }
 
@@ -1722,9 +1727,9 @@
         }
         try {
             evSwitch = debugEvents.registerEvent(
-                               Counters.prefix, "switchevent",
-                               "Switch connected, disconnected or port changed",
-                               EventType.ALWAYS_LOG, SwitchEvent.class, 100);
+                    Counters.prefix, "switchevent",
+                    "Switch connected, disconnected or port changed",
+                    EventType.ALWAYS_LOG, SwitchEvent.class, 100);
         } catch (MaxEventsRegistered e) {
             throw new FloodlightModuleException("Max events registered", e);
         }
@@ -1749,7 +1754,7 @@
 
     @Override
     public void setAlwaysClearFlowsOnSwActivate(boolean value) {
-        //this.alwaysClearFlowsOnSwActivate = value;
+        // this.alwaysClearFlowsOnSwActivate = value;
         // XXX S need to be a little more careful about this
     }
 
@@ -1770,6 +1775,7 @@
 
     /**
      * Forward to the driver-manager to get an IOFSwitch instance.
+     * 
      * @param desc
      * @return
      */
@@ -1782,16 +1788,17 @@
     }
 
     /**
-     * Part of the controller updates framework (see 'run()' method)
-     * Use this method to add an IUpdate. A thread-pool will serve the update
-     * by dispatching it to all listeners for that update.
+     * Part of the controller updates framework (see 'run()' method) Use this
+     * method to add an IUpdate. A thread-pool will serve the update by
+     * dispatching it to all listeners for that update.
+     * 
      * @param update
      */
-    @LogMessageDoc(level="WARN",
-            message="Failure adding update {} to queue",
-            explanation="The controller tried to add an internal notification" +
-                        " to its message queue but the add failed.",
-            recommendation=LogMessageDoc.REPORT_CONTROLLER_BUG)
+    @LogMessageDoc(level = "WARN",
+            message = "Failure adding update {} to queue",
+            explanation = "The controller tried to add an internal notification" +
+                    " to its message queue but the add failed.",
+            recommendation = LogMessageDoc.REPORT_CONTROLLER_BUG)
     private void addUpdateToQueue(IUpdate update) {
         try {
             this.updates.put(update);
@@ -1810,7 +1817,7 @@
 
     /**
      * flcontext_free - Free the context to the current thread
-     *
+     * 
      * @param flcontext
      */
     protected void flcontext_free(FloodlightContext flcontext) {
@@ -1825,7 +1832,6 @@
         System.exit(1);
     }
 
-
     // ***************
     // Floodlight context related
     // ***************
@@ -1842,8 +1848,9 @@
             };
 
     /**
-     * flcontext_alloc - pop a context off the stack, if required create a new one
-     *
+     * flcontext_alloc - pop a context off the stack, if required create a new
+     * one
+     * 
      * @return FloodlightContext
      */
     protected static FloodlightContext flcontext_alloc() {
@@ -1858,5 +1865,4 @@
         return flcontext;
     }
 
-
 }
diff --git a/src/main/java/net/floodlightcontroller/core/internal/OFChannelHandler.java b/src/main/java/net/floodlightcontroller/core/internal/OFChannelHandler.java
index 2008697..aa23852 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/OFChannelHandler.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/OFChannelHandler.java
@@ -74,17 +74,17 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
 /**
- * Channel handler deals with the switch connection and dispatches
- * switch messages to the appropriate locations.
+ * Channel handler deals with the switch connection and dispatches switch
+ * messages to the appropriate locations.
+ * 
  * @author readams, gregor, saurav
  */
 class OFChannelHandler extends IdleStateAwareChannelHandler {
 
     private static final Logger log = LoggerFactory.getLogger(OFChannelHandler.class);
 
-    private static final long DEFAULT_ROLE_TIMEOUT_MS = 10*1000; // 10 sec
+    private static final long DEFAULT_ROLE_TIMEOUT_MS = 10 * 1000; // 10 sec
     private final Controller controller;
     private final Counters counters;
     private IOFSwitch sw;
@@ -94,9 +94,10 @@
     // needs to check if the handshake is complete
     private volatile ChannelState state;
 
-
-    // All role messaging is handled by the roleChanger. The channel state machine
-    // coordinates between the roleChanger and the controller-global-registry-service
+    // All role messaging is handled by the roleChanger. The channel state
+    // machine
+    // coordinates between the roleChanger and the
+    // controller-global-registry-service
     // to determine controller roles per switch.
     private RoleChanger roleChanger;
     // Used to coordinate between the controller and the cleanup thread(?)
@@ -105,7 +106,8 @@
     // When a switch with a duplicate dpid is found (i.e we already have a
     // connected switch with the same dpid), the new switch is immediately
     // disconnected. At that point netty callsback channelDisconnected() which
-    // proceeds to cleaup switch state - we need to ensure that it does not cleanup
+    // proceeds to cleaup switch state - we need to ensure that it does not
+    // cleanup
     // switch state for the older (still connected) switch
     private volatile Boolean duplicateDpidFound;
 
@@ -116,19 +118,20 @@
     // before we are ready to deal with them
     private final CopyOnWriteArrayList<OFPortStatus> pendingPortStatusMsg;
 
-    //Indicates the openflow version used by this switch
+    // Indicates the openflow version used by this switch
     protected OFVersion ofVersion;
     protected static OFFactory factory13;
     protected static OFFactory factory10;
 
-    /** transaction Ids to use during handshake. Since only one thread
-     * calls into an OFChannelHandler instance, we don't need atomic.
-     * We will count down
+    /**
+     * transaction Ids to use during handshake. Since only one thread calls into
+     * an OFChannelHandler instance, we don't need atomic. We will count down
      */
     private int handshakeTransactionIds = -1;
 
     /**
      * Create a new unconnected OFChannelHandler.
+     * 
      * @param controller
      */
     OFChannelHandler(Controller controller) {
@@ -143,59 +146,62 @@
         duplicateDpidFound = Boolean.FALSE;
     }
 
-    //*******************
-    //  Role Handling
-    //*******************
-
+    // *******************
+    // Role Handling
+    // *******************
 
     /**
      * When we remove a pending role request we use this enum to indicate how we
      * arrived at the decision. When we send a role request to the switch, we
-     * also use  this enum to indicate what we expect back from the switch, so the
-     * role changer can match the reply to our expectation.
+     * also use this enum to indicate what we expect back from the switch, so
+     * the role changer can match the reply to our expectation.
+     * 
      * @author gregor, saurav
      */
     public enum RoleRecvStatus {
-        /** The switch returned an error indicating that roles are not
-         * supported*/
+        /**
+         * The switch returned an error indicating that roles are not supported
+         */
         UNSUPPORTED,
         /** The request timed out */
         NO_REPLY,
         /** The reply was old, there is a newer request pending */
         OLD_REPLY,
         /**
-         *  The reply's role matched the role that this controller set in the
-         *  request message - invoked either initially at startup or to reassert
-         *  current role
+         * The reply's role matched the role that this controller set in the
+         * request message - invoked either initially at startup or to reassert
+         * current role
          */
         MATCHED_CURRENT_ROLE,
         /**
-         *  The reply's role matched the role that this controller set in the
-         *  request message - this is the result of a callback from the
-         *  global registry, followed by a role request sent to the switch
+         * The reply's role matched the role that this controller set in the
+         * request message - this is the result of a callback from the global
+         * registry, followed by a role request sent to the switch
          */
         MATCHED_SET_ROLE,
         /**
          * The reply's role was a response to the query made by this controller
          */
         REPLY_QUERY,
-        /** We received a role reply message from the switch
-         *  but the expectation was unclear, or there was no expectation
+        /**
+         * We received a role reply message from the switch but the expectation
+         * was unclear, or there was no expectation
          */
         OTHER_EXPECTATION,
     }
 
     /**
      * Forwards to RoleChanger. See there.
+     * 
      * @param role
      */
     public void sendRoleRequest(Role role, RoleRecvStatus expectation) {
         try {
             roleChanger.sendRoleRequest(role, expectation);
         } catch (IOException e) {
-             log.error("Disconnecting switch {} due to IO Error: {}",
-                              getSwitchInfoString(), e.getMessage());
-             channel.close();
+            log.error("Disconnecting switch {} due to IO Error: {}",
+                    getSwitchInfoString(), e.getMessage());
+            channel.close();
         }
     }
 
@@ -207,15 +213,16 @@
     /**
      * A utility class to handle role requests and replies for this channel.
      * After a role request is submitted the role changer keeps track of the
-     * pending request, collects the reply (if any) and times out the request
-     * if necessary.
-     *
-     * To simplify role handling we only keep track of the /last/ pending
-     * role reply send to the switch. If multiple requests are pending and
-     * we receive replies for earlier requests we ignore them. However, this
-     * way of handling pending requests implies that we could wait forever if
-     * a new request is submitted before the timeout triggers. If necessary
-     * we could work around that though.
+     * pending request, collects the reply (if any) and times out the request if
+     * necessary.
+     * 
+     * To simplify role handling we only keep track of the /last/ pending role
+     * reply send to the switch. If multiple requests are pending and we receive
+     * replies for earlier requests we ignore them. However, this way of
+     * handling pending requests implies that we could wait forever if a new
+     * request is submitted before the timeout triggers. If necessary we could
+     * work around that though.
+     * 
      * @author gregor
      * @author saurav (added support OF1.3 role messages, and expectations)
      */
@@ -246,7 +253,7 @@
         /**
          * Send NX role request message to the switch requesting the specified
          * role.
-         *
+         * 
          * @param sw switch to send the role request message to
          * @param role role to request
          */
@@ -272,7 +279,7 @@
                     .setRole(roleToSend)
                     .build();
             sw.write(Collections.<OFMessage>singletonList(roleRequest),
-                     new FloodlightContext());
+                    new FloodlightContext());
             return xid;
         }
 
@@ -306,24 +313,25 @@
         }
 
         /**
-         * Send a role request with the given role to the switch and update
-         * the pending request and timestamp.
-         * Sends an OFPT_ROLE_REQUEST to an OF1.3 switch, OR
-         * Sends an NX_ROLE_REQUEST to an OF1.0 switch if configured to support it
-         * in the IOFSwitch driver. If not supported, this method sends nothing
-         * and returns 'false'. The caller should take appropriate action.
-         *
+         * Send a role request with the given role to the switch and update the
+         * pending request and timestamp. Sends an OFPT_ROLE_REQUEST to an OF1.3
+         * switch, OR Sends an NX_ROLE_REQUEST to an OF1.0 switch if configured
+         * to support it in the IOFSwitch driver. If not supported, this method
+         * sends nothing and returns 'false'. The caller should take appropriate
+         * action.
+         * 
          * One other optimization we do here is that for OF1.0 switches with
          * Nicira role message support, we force the Role.EQUAL to become
-         * Role.SLAVE, as there is no defined behavior for the Nicira role OTHER.
-         * We cannot expect it to behave like SLAVE. We don't have this problem with
-         * OF1.3 switches, because Role.EQUAL is well defined and we can simulate
-         * SLAVE behavior by using ASYNC messages.
-         *
+         * Role.SLAVE, as there is no defined behavior for the Nicira role
+         * OTHER. We cannot expect it to behave like SLAVE. We don't have this
+         * problem with OF1.3 switches, because Role.EQUAL is well defined and
+         * we can simulate SLAVE behavior by using ASYNC messages.
+         * 
          * @param role
          * @throws IOException
-         * @returns false if and only if the switch does not support role-request
-         * messages, according to the switch driver; true otherwise.
+         * @returns false if and only if the switch does not support
+         *          role-request messages, according to the switch driver; true
+         *          otherwise.
          */
         synchronized boolean sendRoleRequest(Role role, RoleRecvStatus expectation)
                 throws IOException {
@@ -333,11 +341,11 @@
                 Boolean supportsNxRole = (Boolean)
                         sw.getAttribute(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE);
                 if (!supportsNxRole) {
-			log.debug("Switch driver indicates no support for Nicira "
-					+ "role request messages. Not sending ...");
-			state.handleUnsentRoleMessage(OFChannelHandler.this, role,
-					expectation);
-			return false;
+                    log.debug("Switch driver indicates no support for Nicira "
+                            + "role request messages. Not sending ...");
+                    state.handleUnsentRoleMessage(OFChannelHandler.this, role,
+                            expectation);
+                    return false;
                 }
                 // OF1.0 switch with support for NX_ROLE_REQUEST vendor extn.
                 // make Role.EQUAL become Role.SLAVE
@@ -358,18 +366,18 @@
 
         /**
          * Deliver a received role reply.
-         *
+         * 
          * Check if a request is pending and if the received reply matches the
-         * the expected pending reply (we check both role and xid) we set
-         * the role for the switch/channel.
-         *
+         * the expected pending reply (we check both role and xid) we set the
+         * role for the switch/channel.
+         * 
          * If a request is pending but doesn't match the reply we ignore it, and
          * return
-         *
+         * 
          * If no request is pending we disconnect with a SwitchStateException
-         *
+         * 
          * @param RoleReplyInfo information about role-reply in format that
-         *                      controller can understand.
+         *        controller can understand.
          * @throws SwitchStateException if no request is pending
          */
         synchronized RoleRecvStatus deliverRoleReply(RoleReplyInfo rri)
@@ -402,21 +410,22 @@
                         + "Switch: {} in State: {}. "
                         + "This controller has no current role for this sw. "
                         + "Ignoring ...", new Object[] {rri,
-                                getSwitchInfoString(), state});
+                        getSwitchInfoString(), state});
                 return RoleRecvStatus.OTHER_EXPECTATION;
             }
 
             int xid = (int) rri.getXid();
             Role role = rri.getRole();
-            // XXX S should check generation id meaningfully and other cases of expectations
+            // XXX S should check generation id meaningfully and other cases of
+            // expectations
             // U64 genId = rri.getGenId();
 
             if (pendingXid != xid) {
                 log.debug("Received older role reply from " +
                         "switch {} ({}). Ignoring. " +
                         "Waiting for {}, xid={}",
-                        new Object[] { getSwitchInfoString(), rri,
-                        pendingRole, pendingXid });
+                        new Object[] {getSwitchInfoString(), rri,
+                                pendingRole, pendingXid});
                 return RoleRecvStatus.OLD_REPLY;
             }
 
@@ -449,12 +458,11 @@
         }
 
         /**
-         * Called if we receive an  error message. If the xid matches the
-         * pending request we handle it otherwise we ignore it.
-         *
-         * Note: since we only keep the last pending request we might get
-         * error messages for earlier role requests that we won't be able
-         * to handle
+         * Called if we receive an error message. If the xid matches the pending
+         * request we handle it otherwise we ignore it.
+         * 
+         * Note: since we only keep the last pending request we might get error
+         * messages for earlier role requests that we won't be able to handle
          */
         synchronized RoleRecvStatus deliverError(OFErrorMsg error)
                 throws SwitchStateException {
@@ -473,17 +481,19 @@
                 }
                 return RoleRecvStatus.OTHER_EXPECTATION;
             }
-            // it is an error related to a currently pending role request message
-            requestPending = false; // we got a response, even though it is an error
+            // it is an error related to a currently pending role request
+            // message
+            requestPending = false; // we got a response, even though it is an
+                                    // error
             if (error.getErrType() == OFErrorType.BAD_REQUEST) {
                 counters.roleReplyErrorUnsupported.updateCounterWithFlush();
                 log.error("Received a error msg {} from sw {} in state {} for "
                         + "pending role request {}. Switch driver indicates "
                         + "role-messaging is supported. Possible issues in "
                         + "switch driver configuration?", new Object[] {
-                                ((OFBadRequestErrorMsg)error).toString(),
-                                getSwitchInfoString(), state, pendingRole
-                        });
+                        ((OFBadRequestErrorMsg) error).toString(),
+                        getSwitchInfoString(), state, pendingRole
+                });
                 return RoleRecvStatus.UNSUPPORTED;
             }
 
@@ -514,21 +524,22 @@
                 }
             }
 
-            // This error message was for a role request message but we dont know
+            // This error message was for a role request message but we dont
+            // know
             // how to handle errors for nicira role request messages
             return RoleRecvStatus.OTHER_EXPECTATION;
         }
 
         /**
          * Check if a pending role request has timed out.
-         *
+         * 
          * @throws SwitchStateException
          */
         void checkTimeout() throws SwitchStateException {
             if (!requestPending) {
                 return;
             }
-            synchronized(this) {
+            synchronized (this) {
                 if (!requestPending)
                     return;
                 long now = System.currentTimeMillis();
@@ -542,16 +553,18 @@
 
     }
 
-    //*************************
-    //  Channel State Machine
-    //*************************
+    // *************************
+    // Channel State Machine
+    // *************************
 
     /**
      * The state machine for handling the switch/channel state. All state
-     * transitions should happen from within the state machine (and not from other
-     * parts of the code)
+     * transitions should happen from within the state machine (and not from
+     * other parts of the code)
+     * 
      * @author gregor
-     * @author saurav (modified to handle 1.0 & 1.3 switches, EQUAL state, role-handling )
+     * @author saurav (modified to handle 1.0 & 1.3 switches, EQUAL state,
+     *         role-handling )
      */
     enum ChannelState {
         /**
@@ -579,11 +592,11 @@
         },
 
         /**
-         * We send a OF 1.3 HELLO to the switch and wait for a Hello from the switch.
-         * Once we receive the reply, we decide on OF 1.3 or 1.0 switch - no other
-         * protocol version is accepted.
-         * We send an OFFeaturesRequest depending on the protocol version selected
-         * Next state is WAIT_FEATURES_REPLY
+         * We send a OF 1.3 HELLO to the switch and wait for a Hello from the
+         * switch. Once we receive the reply, we decide on OF 1.3 or 1.0 switch
+         * - no other protocol version is accepted. We send an OFFeaturesRequest
+         * depending on the protocol version selected Next state is
+         * WAIT_FEATURES_REPLY
          */
         WAIT_HELLO(false) {
             @Override
@@ -611,17 +624,20 @@
                 h.sendHandshakeFeaturesRequestMessage();
                 h.setState(WAIT_FEATURES_REPLY);
             }
+
             @Override
-            void processOFFeaturesReply(OFChannelHandler h, OFFeaturesReply  m)
+            void processOFFeaturesReply(OFChannelHandler h, OFFeaturesReply m)
                     throws IOException, SwitchStateException {
                 illegalMessageReceived(h, m);
             }
+
             @Override
             void processOFStatisticsReply(OFChannelHandler h,
-                                          OFStatsReply  m)
+                    OFStatsReply m)
                     throws IOException, SwitchStateException {
                 illegalMessageReceived(h, m);
             }
+
             @Override
             void processOFError(OFChannelHandler h, OFErrorMsg m) {
                 logErrorDisconnect(h, m);
@@ -634,22 +650,21 @@
             }
         },
 
-
         /**
          * We are waiting for a features reply message. Once we receive it, the
-         * behavior depends on whether this is a 1.0 or 1.3 switch. For 1.0,
-         * we send a SetConfig request, barrier, and GetConfig request and the
-         * next state is WAIT_CONFIG_REPLY. For 1.3, we send a Port description
+         * behavior depends on whether this is a 1.0 or 1.3 switch. For 1.0, we
+         * send a SetConfig request, barrier, and GetConfig request and the next
+         * state is WAIT_CONFIG_REPLY. For 1.3, we send a Port description
          * request and the next state is WAIT_PORT_DESC_REPLY.
          */
         WAIT_FEATURES_REPLY(false) {
             @Override
-            void processOFFeaturesReply(OFChannelHandler h, OFFeaturesReply  m)
+            void processOFFeaturesReply(OFChannelHandler h, OFFeaturesReply m)
                     throws IOException {
                 h.thisdpid = m.getDatapathId().getLong();
                 log.info("Received features reply for switch at {} with dpid {}",
                         h.getSwitchInfoString(), h.thisdpid);
-                //update the controller about this connected switch
+                // update the controller about this connected switch
                 boolean success = h.controller.addConnectedSwitch(
                         h.thisdpid, h);
                 if (!success) {
@@ -657,22 +672,24 @@
                     return;
                 }
 
-                h.featuresReply = m; //temp store
+                h.featuresReply = m; // temp store
                 if (h.ofVersion == OFVersion.OF_10) {
                     h.sendHandshakeSetConfig();
                     h.setState(WAIT_CONFIG_REPLY);
                 } else {
-                    //version is 1.3, must get switchport information
+                    // version is 1.3, must get switchport information
                     h.sendHandshakeOFPortDescRequest();
                     h.setState(WAIT_PORT_DESC_REPLY);
                 }
             }
+
             @Override
             void processOFStatisticsReply(OFChannelHandler h,
-                                          OFStatsReply  m)
+                    OFStatsReply m)
                     throws IOException, SwitchStateException {
                 illegalMessageReceived(h, m);
             }
+
             @Override
             void processOFError(OFChannelHandler h, OFErrorMsg m) {
                 logErrorDisconnect(h, m);
@@ -686,9 +703,8 @@
         },
 
         /**
-         * We are waiting for a description of the 1.3 switch ports.
-         * Once received, we send a SetConfig request
-         * Next State is WAIT_CONFIG_REPLY
+         * We are waiting for a description of the 1.3 switch ports. Once
+         * received, we send a SetConfig request Next State is WAIT_CONFIG_REPLY
          */
         WAIT_PORT_DESC_REPLY(false) {
 
@@ -707,7 +723,7 @@
                             + "port description - not currently handled",
                             h.getSwitchInfoString());
                 }
-                h.portDescReply = (OFPortDescStatsReply)m; // temp store
+                h.portDescReply = (OFPortDescStatsReply) m; // temp store
                 log.info("Received port desc reply for switch at {}",
                         h.getSwitchInfoString());
                 try {
@@ -735,21 +751,21 @@
         },
 
         /**
-         * We are waiting for a config reply message. Once we receive it
-         * we send a DescriptionStatsRequest to the switch.
-         * Next state: WAIT_DESCRIPTION_STAT_REPLY
+         * We are waiting for a config reply message. Once we receive it we send
+         * a DescriptionStatsRequest to the switch. Next state:
+         * WAIT_DESCRIPTION_STAT_REPLY
          */
         WAIT_CONFIG_REPLY(false) {
             @Override
             @LogMessageDocs({
-                @LogMessageDoc(level="WARN",
-                        message="Config Reply from {switch} has " +
-                                "miss length set to {length}",
-                        explanation="The controller requires that the switch " +
-                                "use a miss length of 0xffff for correct " +
-                                "function",
-                        recommendation="Use a different switch to ensure " +
-                                "correct function")
+                    @LogMessageDoc(level = "WARN",
+                            message = "Config Reply from {switch} has " +
+                                    "miss length set to {length}",
+                            explanation = "The controller requires that the switch " +
+                                    "use a miss length of 0xffff for correct " +
+                                    "function",
+                            recommendation = "Use a different switch to ensure " +
+                                    "correct function")
             })
             void processOFGetConfigReply(OFChannelHandler h, OFGetConfigReply m)
                     throws IOException {
@@ -775,13 +791,14 @@
             }
 
             @Override
-            void processOFFeaturesReply(OFChannelHandler h, OFFeaturesReply  m)
+            void processOFFeaturesReply(OFChannelHandler h, OFFeaturesReply m)
                     throws IOException, SwitchStateException {
                 illegalMessageReceived(h, m);
             }
+
             @Override
             void processOFStatisticsReply(OFChannelHandler h,
-                                          OFStatsReply  m)
+                    OFStatsReply m)
                     throws IOException, SwitchStateException {
                 log.error("Received multipart(stats) message sub-type {}",
                         m.getStatsType());
@@ -800,29 +817,26 @@
             }
         },
 
-
         /**
-         * We are waiting for a OFDescriptionStat message from the switch.
-         * Once we receive any stat message we try to parse it. If it's not
-         * a description stats message we disconnect. If its the expected
-         * description stats message, we:
-         *    - use the switch driver to bind the switch and get an IOFSwitch instance
-         *    - setup the IOFSwitch instance
-         *    - add switch to FloodlightProvider(Controller) and send the initial role
-         *      request to the switch.
-         * Next state: WAIT_INITIAL_ROLE
-         *      In the typical case, where switches support role request messages
-         *      the next state is where we expect the role reply message.
-         *      In the special case that where the switch does not support any kind
-         *      of role request messages, we don't send a role message, but we do
-         *      request mastership from the registry service. This controller
-         *      should become master once we hear back from the registry service.
-         * All following states will have a h.sw instance!
+         * We are waiting for a OFDescriptionStat message from the switch. Once
+         * we receive any stat message we try to parse it. If it's not a
+         * description stats message we disconnect. If its the expected
+         * description stats message, we: - use the switch driver to bind the
+         * switch and get an IOFSwitch instance - setup the IOFSwitch instance -
+         * add switch to FloodlightProvider(Controller) and send the initial
+         * role request to the switch. Next state: WAIT_INITIAL_ROLE In the
+         * typical case, where switches support role request messages the next
+         * state is where we expect the role reply message. In the special case
+         * that where the switch does not support any kind of role request
+         * messages, we don't send a role message, but we do request mastership
+         * from the registry service. This controller should become master once
+         * we hear back from the registry service. All following states will
+         * have a h.sw instance!
          */
         WAIT_DESCRIPTION_STAT_REPLY(false) {
-            @LogMessageDoc(message="Switch {switch info} bound to class " +
-                "{switch driver}, description {switch description}",
-                    explanation="The specified switch has been bound to " +
+            @LogMessageDoc(message = "Switch {switch info} bound to class " +
+                    "{switch driver}, description {switch description}",
+                    explanation = "The specified switch has been bound to " +
                             "a switch driver based on the switch description" +
                             "received from the switch")
             @Override
@@ -838,7 +852,8 @@
                 log.info("Received switch description reply from switch at {}",
                         h.channel.getRemoteAddress());
                 OFDescStatsReply drep = (OFDescStatsReply) m;
-                // Here is where we differentiate between different kinds of switches
+                // Here is where we differentiate between different kinds of
+                // switches
                 h.sw = h.controller.getOFSwitchInstance(drep, h.ofVersion);
                 // set switch information
                 h.sw.setOFVersion(h.ofVersion);
@@ -854,12 +869,13 @@
                     h.counters.switchCounterRegistrationFailed
                             .updateCounterNoFlush();
                     log.warn("Could not register counters for switch {} ",
-                              h.getSwitchInfoString(), e);
+                            h.getSwitchInfoString(), e);
                 }
 
                 log.info("Switch {} bound to class {}, description {}",
-                         new Object[] { h.sw, h.sw.getClass(), drep });
-                //Put switch in EQUAL mode until we hear back from the global registry
+                        new Object[] {h.sw, h.sw.getClass(), drep});
+                // Put switch in EQUAL mode until we hear back from the global
+                // registry
                 log.debug("Setting new switch {} to EQUAL and sending Role request",
                         h.sw.getStringId());
                 h.setSwitchRole(Role.EQUAL);
@@ -891,7 +907,7 @@
             }
 
             @Override
-            void processOFFeaturesReply(OFChannelHandler h, OFFeaturesReply  m)
+            void processOFFeaturesReply(OFChannelHandler h, OFFeaturesReply m)
                     throws IOException, SwitchStateException {
                 illegalMessageReceived(h, m);
             }
@@ -908,13 +924,13 @@
          * sent after hearing back from the registry service -- OR -- we are
          * just waiting to hear back from the registry service in the case that
          * the switch does not support role messages. If completed successfully,
-         * the controller's role for this switch will be set here.
-         * Before we move to the state corresponding to the role, we allow the
-         * switch specific driver to complete its configuration. This configuration
-         * typically depends on the role the controller is playing for this switch.
-         * And so we set the switch role (for 'this' controller) before we start
-         * the driver-sub-handshake.
-         * Next State: WAIT_SWITCH_DRIVER_SUB_HANDSHAKE
+         * the controller's role for this switch will be set here. Before we
+         * move to the state corresponding to the role, we allow the switch
+         * specific driver to complete its configuration. This configuration
+         * typically depends on the role the controller is playing for this
+         * switch. And so we set the switch role (for 'this' controller) before
+         * we start the driver-sub-handshake. Next State:
+         * WAIT_SWITCH_DRIVER_SUB_HANDSHAKE
          */
         WAIT_INITIAL_ROLE(false) {
             @Override
@@ -947,7 +963,7 @@
             @Override
             void processOFRoleReply(OFChannelHandler h, OFRoleReply m)
                     throws SwitchStateException, IOException {
-                RoleReplyInfo rri = extractOFRoleReply(h,m);
+                RoleReplyInfo rri = extractOFRoleReply(h, m);
                 RoleRecvStatus rrs = h.roleChanger.deliverRoleReply(rri);
                 if (rrs == RoleRecvStatus.MATCHED_SET_ROLE) {
                     setRoleAndStartDriverHandshake(h, rri.getRole());
@@ -956,22 +972,22 @@
 
             @Override
             void handleUnsentRoleMessage(OFChannelHandler h, Role role,
-            		RoleRecvStatus expectation) throws IOException {
-            	// typically this is triggered for a switch where role messages
-            	// are not supported - we confirm that the role being set is
-            	// master and move to the next state
-            	if (expectation == RoleRecvStatus.MATCHED_SET_ROLE) {
-            		if (role == Role.MASTER) {
-            			setRoleAndStartDriverHandshake(h, role);
-            		} else {
-            			log.error("Expected MASTER role from registry for switch "
-            					+ "which has no support for role-messages."
-            					+ "Received {}. It is possible that this switch "
-            					+ "is connected to other controllers, in which "
-            					+ "case it should support role messages - not "
-            					+ "moving forward.", role);
-            		}
-            	} // else do nothing - wait to hear back from registry
+                    RoleRecvStatus expectation) throws IOException {
+                // typically this is triggered for a switch where role messages
+                // are not supported - we confirm that the role being set is
+                // master and move to the next state
+                if (expectation == RoleRecvStatus.MATCHED_SET_ROLE) {
+                    if (role == Role.MASTER) {
+                        setRoleAndStartDriverHandshake(h, role);
+                    } else {
+                        log.error("Expected MASTER role from registry for switch "
+                                + "which has no support for role-messages."
+                                + "Received {}. It is possible that this switch "
+                                + "is connected to other controllers, in which "
+                                + "case it should support role messages - not "
+                                + "moving forward.", role);
+                    }
+                } // else do nothing - wait to hear back from registry
 
             }
 
@@ -985,7 +1001,7 @@
                         log.info("Switch-driver sub-handshake complete. "
                                 + "Activating switch {} with Role: MASTER",
                                 h.getSwitchInfoString());
-                        handlePendingPortStatusMessages(h); //before activation
+                        handlePendingPortStatusMessages(h); // before activation
                         boolean success = h.controller.addActivatedMasterSwitch(
                                 h.sw.getId(), h.sw);
                         if (!success) {
@@ -997,7 +1013,7 @@
                         log.info("Switch-driver sub-handshake complete. "
                                 + "Activating switch {} with Role: EQUAL",
                                 h.getSwitchInfoString());
-                        handlePendingPortStatusMessages(h); //before activation
+                        handlePendingPortStatusMessages(h); // before activation
                         boolean success = h.controller.addActivatedEqualSwitch(
                                 h.sw.getId(), h.sw);
                         if (!success) {
@@ -1012,7 +1028,7 @@
             }
 
             @Override
-            void processOFFeaturesReply(OFChannelHandler h, OFFeaturesReply  m)
+            void processOFFeaturesReply(OFChannelHandler h, OFFeaturesReply m)
                     throws IOException, SwitchStateException {
                 illegalMessageReceived(h, m);
             }
@@ -1033,11 +1049,11 @@
 
         /**
          * We are waiting for the respective switch driver to complete its
-         * configuration. Notice that we do not consider this to be part of the main
-         * switch-controller handshake. But we do consider it as a step that comes
-         * before we declare the switch as available to the controller.
-         * Next State: depends on the role of this controller for this switch - either
-         * MASTER or EQUAL.
+         * configuration. Notice that we do not consider this to be part of the
+         * main switch-controller handshake. But we do consider it as a step
+         * that comes before we declare the switch as available to the
+         * controller. Next State: depends on the role of this controller for
+         * this switch - either MASTER or EQUAL.
          */
         WAIT_SWITCH_DRIVER_SUB_HANDSHAKE(true) {
 
@@ -1051,7 +1067,7 @@
             void processOFMessage(OFChannelHandler h, OFMessage m)
                     throws IOException {
                 if (m.getType() == OFType.ECHO_REQUEST)
-                    processOFEchoRequest(h, (OFEchoRequest)m);
+                    processOFEchoRequest(h, (OFEchoRequest) m);
                 else {
                     // FIXME: other message to handle here?
                     h.sw.processDriverHandshakeMessage(m);
@@ -1062,7 +1078,8 @@
                             log.info("Switch-driver sub-handshake complete. "
                                     + "Activating switch {} with Role: MASTER",
                                     h.getSwitchInfoString());
-                            handlePendingPortStatusMessages(h); //before activation
+                            handlePendingPortStatusMessages(h); // before
+                                                                // activation
                             boolean success = h.controller.addActivatedMasterSwitch(
                                     h.sw.getId(), h.sw);
                             if (!success) {
@@ -1074,7 +1091,8 @@
                             log.info("Switch-driver sub-handshake complete. "
                                     + "Activating switch {} with Role: EQUAL",
                                     h.getSwitchInfoString());
-                            handlePendingPortStatusMessages(h); //before activation
+                            handlePendingPortStatusMessages(h); // before
+                                                                // activation
                             boolean success = h.controller.addActivatedEqualSwitch(
                                     h.sw.getId(), h.sw);
                             if (!success) {
@@ -1094,43 +1112,40 @@
             }
         },
 
-
         /**
-         * This controller is in MASTER role for this switch. We enter this state
-         * after requesting and winning control from the global registry.
-         * The main handshake as well as the switch-driver sub-handshake
-         * is complete at this point.
-         * // XXX S reconsider below
-         * In the (near) future we may deterministically assign controllers to
-         * switches at startup.
-         * We only leave this state if the switch disconnects or
-         * if we send a role request for SLAVE /and/ receive the role reply for
-         * SLAVE.
+         * This controller is in MASTER role for this switch. We enter this
+         * state after requesting and winning control from the global registry.
+         * The main handshake as well as the switch-driver sub-handshake is
+         * complete at this point. // XXX S reconsider below In the (near)
+         * future we may deterministically assign controllers to switches at
+         * startup. We only leave this state if the switch disconnects or if we
+         * send a role request for SLAVE /and/ receive the role reply for SLAVE.
          */
         MASTER(true) {
-            @LogMessageDoc(level="WARN",
-                message="Received permission error from switch {} while" +
-                         "being master. Reasserting master role.",
-                explanation="The switch has denied an operation likely " +
-                         "indicating inconsistent controller roles",
-                recommendation="This situation can occurs transiently during role" +
-                 " changes. If, however, the condition persists or happens" +
-                 " frequently this indicates a role inconsistency. " +
-                 LogMessageDoc.CHECK_CONTROLLER )
+            @LogMessageDoc(level = "WARN",
+                    message = "Received permission error from switch {} while" +
+                            "being master. Reasserting master role.",
+                    explanation = "The switch has denied an operation likely " +
+                            "indicating inconsistent controller roles",
+                    recommendation = "This situation can occurs transiently during role" +
+                            " changes. If, however, the condition persists or happens" +
+                            " frequently this indicates a role inconsistency. " +
+                            LogMessageDoc.CHECK_CONTROLLER)
             @Override
             void processOFError(OFChannelHandler h, OFErrorMsg m)
                     throws IOException, SwitchStateException {
-                // first check if the error msg is in response to a role-request message
+                // first check if the error msg is in response to a role-request
+                // message
                 RoleRecvStatus rrstatus = h.roleChanger.deliverError(m);
                 if (rrstatus != RoleRecvStatus.OTHER_EXPECTATION) {
-			// rolechanger has handled the error message - we are done
+                    // rolechanger has handled the error message - we are done
                     return;
                 }
 
                 // if we get here, then the error message is for something else
                 if (m.getErrType() == OFErrorType.BAD_REQUEST &&
                         ((OFBadRequestErrorMsg) m).getCode() ==
-                            OFBadRequestCode.EPERM) {
+                        OFBadRequestCode.EPERM) {
                     // We are the master controller and the switch returned
                     // a permission error. This is a likely indicator that
                     // the switch thinks we are slave. Reassert our
@@ -1141,14 +1156,14 @@
                     // persist before we reassert
                     h.counters.epermErrorWhileSwitchIsMaster.updateCounterWithFlush();
                     log.warn("Received permission error from switch {} while" +
-                             "being master. Reasserting master role.",
-                             h.getSwitchInfoString());
-                    //h.controller.reassertRole(h, Role.MASTER);
+                            "being master. Reasserting master role.",
+                            h.getSwitchInfoString());
+                    // h.controller.reassertRole(h, Role.MASTER);
                     // XXX S reassert in role changer or reconsider if all this
                     // stuff is really needed
                 } else if (m.getErrType() == OFErrorType.FLOW_MOD_FAILED &&
-                            ((OFFlowModFailedErrorMsg) m).getCode() ==
-                                OFFlowModFailedCode.ALL_TABLES_FULL) {
+                        ((OFFlowModFailedErrorMsg) m).getCode() ==
+                        OFFlowModFailedCode.ALL_TABLES_FULL) {
                     h.sw.setTableFull(true);
                 } else {
                     logError(h, m);
@@ -1158,7 +1173,7 @@
 
             @Override
             void processOFStatisticsReply(OFChannelHandler h,
-                                          OFStatsReply m) {
+                    OFStatsReply m) {
                 h.sw.deliverStatisticsReply(m);
             }
 
@@ -1167,16 +1182,16 @@
                     throws IOException, SwitchStateException {
                 Role role = extractNiciraRoleReply(h, m);
                 if (role == null) {
-			// The message wasn't really a Nicira role reply. We just
-			// dispatch it to the OFMessage listeners in this case.
-			h.dispatchMessage(m);
-			return;
+                    // The message wasn't really a Nicira role reply. We just
+                    // dispatch it to the OFMessage listeners in this case.
+                    h.dispatchMessage(m);
+                    return;
                 }
 
                 RoleRecvStatus rrs = h.roleChanger.deliverRoleReply(
-				new RoleReplyInfo(role, null, m.getXid()));
+                        new RoleReplyInfo(role, null, m.getXid()));
                 if (rrs == RoleRecvStatus.MATCHED_SET_ROLE) {
-			checkAndSetRoleTransition(h, role);
+                    checkAndSetRoleTransition(h, role);
                 }
             }
 
@@ -1186,7 +1201,7 @@
                 RoleReplyInfo rri = extractOFRoleReply(h, m);
                 RoleRecvStatus rrs = h.roleChanger.deliverRoleReply(rri);
                 if (rrs == RoleRecvStatus.MATCHED_SET_ROLE) {
-			checkAndSetRoleTransition(h, rri.getRole());
+                    checkAndSetRoleTransition(h, rri.getRole());
                 }
             }
 
@@ -1205,14 +1220,14 @@
 
             @Override
             void processOFFlowRemoved(OFChannelHandler h,
-                                      OFFlowRemoved m) throws IOException {
+                    OFFlowRemoved m) throws IOException {
                 h.dispatchMessage(m);
             }
 
             @Override
             void processOFBarrierReply(OFChannelHandler h, OFBarrierReply m)
                     throws IOException {
-		h.dispatchMessage(m);
+                h.dispatchMessage(m);
             }
 
         },
@@ -1223,15 +1238,16 @@
          * switch. The EQUAL role can be considered the same as the SLAVE role
          * if this controller does NOT send commands or packets to the switch.
          * This should always be true for OF1.0 switches. XXX S need to enforce.
-         *
+         * 
          * For OF1.3 switches, choosing this state as EQUAL instead of SLAVE,
-         * gives us the flexibility that if an app wants to send commands/packets
-         * to switches, it can, even thought it is running on a controller instance
-         * that is not in a MASTER role for this switch. Of course, it is the job
-         * of the app to ensure that commands/packets sent by this (EQUAL) controller
-         * instance does not clash/conflict with commands/packets sent by the MASTER
-         * controller for this switch. Neither the controller instances, nor the
-         * switch provides any kind of resolution mechanism should conflicts occur.
+         * gives us the flexibility that if an app wants to send
+         * commands/packets to switches, it can, even thought it is running on a
+         * controller instance that is not in a MASTER role for this switch. Of
+         * course, it is the job of the app to ensure that commands/packets sent
+         * by this (EQUAL) controller instance does not clash/conflict with
+         * commands/packets sent by the MASTER controller for this switch.
+         * Neither the controller instances, nor the switch provides any kind of
+         * resolution mechanism should conflicts occur.
          */
         EQUAL(true) {
             @Override
@@ -1247,7 +1263,7 @@
 
             @Override
             void processOFStatisticsReply(OFChannelHandler h,
-                                          OFStatsReply m) {
+                    OFStatsReply m) {
                 h.sw.deliverStatisticsReply(m);
             }
 
@@ -1258,10 +1274,10 @@
                 // If role == null it means the message wasn't really a
                 // Nicira role reply. We ignore it in this state.
                 if (role != null) {
-			RoleRecvStatus rrs = h.roleChanger.deliverRoleReply(
+                    RoleRecvStatus rrs = h.roleChanger.deliverRoleReply(
                             new RoleReplyInfo(role, null, m.getXid()));
-			if (rrs == RoleRecvStatus.MATCHED_SET_ROLE) {
-			checkAndSetRoleTransition(h, role);
+                    if (rrs == RoleRecvStatus.MATCHED_SET_ROLE) {
+                        checkAndSetRoleTransition(h, role);
                     }
                 } else {
                     unhandledMessageReceived(h, m);
@@ -1274,7 +1290,7 @@
                 RoleReplyInfo rri = extractOFRoleReply(h, m);
                 RoleRecvStatus rrs = h.roleChanger.deliverRoleReply(rri);
                 if (rrs == RoleRecvStatus.MATCHED_SET_ROLE) {
-			checkAndSetRoleTransition(h, rri.getRole());
+                    checkAndSetRoleTransition(h, rri.getRole());
                 }
             }
 
@@ -1287,32 +1303,34 @@
             }
 
             @Override
-            @LogMessageDoc(level="WARN",
-                message="Received PacketIn from switch {} while" +
-                         "being slave. Reasserting slave role.",
-                explanation="The switch has receive a PacketIn despite being " +
-                         "in slave role indicating inconsistent controller roles",
-                recommendation="This situation can occurs transiently during role" +
-                         " changes. If, however, the condition persists or happens" +
-                         " frequently this indicates a role inconsistency. " +
-                         LogMessageDoc.CHECK_CONTROLLER )
+            @LogMessageDoc(level = "WARN",
+                    message = "Received PacketIn from switch {} while" +
+                            "being slave. Reasserting slave role.",
+                    explanation = "The switch has receive a PacketIn despite being " +
+                            "in slave role indicating inconsistent controller roles",
+                    recommendation = "This situation can occurs transiently during role" +
+                            " changes. If, however, the condition persists or happens" +
+                            " frequently this indicates a role inconsistency. " +
+                            LogMessageDoc.CHECK_CONTROLLER)
             void processOFPacketIn(OFChannelHandler h, OFPacketIn m) throws IOException {
                 // we don't expect packetIn while slave, reassert we are slave
                 h.counters.packetInWhileSwitchIsSlave.updateCounterNoFlush();
                 log.warn("Received PacketIn from switch {} while" +
-                         "being slave. Reasserting slave role.", h.sw);
-                //h.controller.reassertRole(h, Role.SLAVE);
+                        "being slave. Reasserting slave role.", h.sw);
+                // h.controller.reassertRole(h, Role.SLAVE);
                 // XXX reassert in role changer
             }
         };
 
         private final boolean handshakeComplete;
+
         ChannelState(boolean handshakeComplete) {
             this.handshakeComplete = handshakeComplete;
         }
 
         /**
          * Is this a state in which the handshake has completed?
+         * 
          * @return true if the handshake is complete
          */
         public boolean isHandshakeComplete() {
@@ -1320,32 +1338,33 @@
         }
 
         /**
-         * Get a string specifying the switch connection, state, and
-         * message received. To be used as message for SwitchStateException
-         * or log messages
+         * Get a string specifying the switch connection, state, and message
+         * received. To be used as message for SwitchStateException or log
+         * messages
+         * 
          * @param h The channel handler (to get switch information_
          * @param m The OFMessage that has just been received
-         * @param details A string giving more details about the exact nature
-         * of the problem.
+         * @param details A string giving more details about the exact nature of
+         *        the problem.
          * @return
          */
         // needs to be protected because enum members are actually subclasses
         protected String getSwitchStateMessage(OFChannelHandler h,
-                                                      OFMessage m,
-                                                      String details) {
+                OFMessage m,
+                String details) {
             return String.format("Switch: [%s], State: [%s], received: [%s]"
-                                 + ", details: %s",
-                                 h.getSwitchInfoString(),
-                                 this.toString(),
-                                 m.getType().toString(),
-                                 details);
+                    + ", details: %s",
+                    h.getSwitchInfoString(),
+                    this.toString(),
+                    m.getType().toString(),
+                    details);
         }
 
         /**
-         * We have an OFMessage we didn't expect given the current state and
-         * we want to treat this as an error.
-         * We currently throw an exception that will terminate the connection
-         * However, we could be more forgiving
+         * We have an OFMessage we didn't expect given the current state and we
+         * want to treat this as an error. We currently throw an exception that
+         * will terminate the connection However, we could be more forgiving
+         * 
          * @param h the channel handler that received the message
          * @param m the message
          * @throws SwitchStateException
@@ -1361,13 +1380,14 @@
         }
 
         /**
-         * We have an OFMessage we didn't expect given the current state and
-         * we want to ignore the message
+         * We have an OFMessage we didn't expect given the current state and we
+         * want to ignore the message
+         * 
          * @param h the channel handler the received the message
          * @param m the message
          */
         protected void unhandledMessageReceived(OFChannelHandler h,
-                                                OFMessage m) {
+                OFMessage m) {
             h.counters.unhandledMessage.updateCounterNoFlush();
             if (log.isDebugEnabled()) {
                 String msg = getSwitchStateMessage(h, m,
@@ -1378,29 +1398,31 @@
 
         /**
          * Log an OpenFlow error message from a switch
+         * 
          * @param sw The switch that sent the error
          * @param error The error message
          */
-        @LogMessageDoc(level="ERROR",
-                message="Error {error type} {error code} from {switch} " +
+        @LogMessageDoc(level = "ERROR",
+                message = "Error {error type} {error code} from {switch} " +
                         "in state {state}",
-                explanation="The switch responded with an unexpected error" +
+                explanation = "The switch responded with an unexpected error" +
                         "to an OpenFlow message from the controller",
-                recommendation="This could indicate improper network operation. " +
+                recommendation = "This could indicate improper network operation. " +
                         "If the problem persists restarting the switch and " +
                         "controller may help."
                 )
-        protected void logError(OFChannelHandler h, OFErrorMsg error) {
+                protected void logError(OFChannelHandler h, OFErrorMsg error) {
             log.error("{} from switch {} in state {}",
-                      new Object[] {
-                          error,
-                          h.getSwitchInfoString(),
-                          this.toString()});
+                    new Object[] {
+                            error,
+                            h.getSwitchInfoString(),
+                            this.toString()});
         }
 
         /**
          * Log an OpenFlow error message from a switch and disconnect the
          * channel
+         * 
          * @param sw The switch that sent the error
          * @param error The error message
          */
@@ -1421,50 +1443,50 @@
 
         /**
          * Extract the role from an OFVendor message.
-         *
-         * Extract the role from an OFVendor message if the message is a
-         * Nicira role reply. Otherwise return null.
-         *
+         * 
+         * Extract the role from an OFVendor message if the message is a Nicira
+         * role reply. Otherwise return null.
+         * 
          * @param h The channel handler receiving the message
          * @param vendorMessage The vendor message to parse.
          * @return The role in the message if the message is a Nicira role
-         * reply, null otherwise.
+         *         reply, null otherwise.
          * @throws SwitchStateException If the message is a Nicira role reply
-         * but the numeric role value is unknown.
+         *         but the numeric role value is unknown.
          */
         protected Role extractNiciraRoleReply(OFChannelHandler h,
-			OFExperimenter experimenterMsg) throws SwitchStateException {
-		int vendor = (int) experimenterMsg.getExperimenter();
-		if (vendor != 0x2320) // magic number representing nicira
-			return null;
-		OFNiciraControllerRoleReply nrr =
-				(OFNiciraControllerRoleReply) experimenterMsg;
+                OFExperimenter experimenterMsg) throws SwitchStateException {
+            int vendor = (int) experimenterMsg.getExperimenter();
+            if (vendor != 0x2320) // magic number representing nicira
+                return null;
+            OFNiciraControllerRoleReply nrr =
+                    (OFNiciraControllerRoleReply) experimenterMsg;
 
-		Role role = null;
-		OFNiciraControllerRole ncr = nrr.getRole();
-		switch(ncr) {
-		case ROLE_MASTER:
-			role = Role.MASTER;
-			break;
-		case ROLE_OTHER:
-			role = Role.EQUAL;
-			break;
-		case ROLE_SLAVE:
-			role = Role.SLAVE;
-			break;
-		default: //handled below
-		}
+            Role role = null;
+            OFNiciraControllerRole ncr = nrr.getRole();
+            switch (ncr) {
+            case ROLE_MASTER:
+                role = Role.MASTER;
+                break;
+            case ROLE_OTHER:
+                role = Role.EQUAL;
+                break;
+            case ROLE_SLAVE:
+                role = Role.SLAVE;
+                break;
+            default: // handled below
+            }
 
-		if (role == null) {
-			String msg = String.format("Switch: [%s], State: [%s], "
-					+ "received NX_ROLE_REPLY with invalid role "
-					+ "value %d",
-					h.getSwitchInfoString(),
-					this.toString(),
-					nrr.getRole());
-			throw new SwitchStateException(msg);
-		}
-		return role;
+            if (role == null) {
+                String msg = String.format("Switch: [%s], State: [%s], "
+                        + "received NX_ROLE_REPLY with invalid role "
+                        + "value %d",
+                        h.getSwitchInfoString(),
+                        this.toString(),
+                        nrr.getRole());
+                throw new SwitchStateException(msg);
+            }
+            return role;
         }
 
         /**
@@ -1476,14 +1498,24 @@
             private U64 genId;
             private long xid;
 
-            RoleReplyInfo (Role role, U64 genId, long xid) {
+            RoleReplyInfo(Role role, U64 genId, long xid) {
                 this.role = role;
                 this.genId = genId;
                 this.xid = xid;
             }
-            public Role getRole() { return role; }
-            public U64 getGenId() { return genId; }
-            public long getXid() { return xid; }
+
+            public Role getRole() {
+                return role;
+            }
+
+            public U64 getGenId() {
+                return genId;
+            }
+
+            public long getXid() {
+                return xid;
+            }
+
             @Override
             public String toString() {
                 return "[Role:" + role + " GenId:" + genId + " Xid:" + xid + "]";
@@ -1492,6 +1524,7 @@
 
         /**
          * Extract the role information from an OF1.3 Role Reply Message
+         * 
          * @param h
          * @param rrmsg
          * @return RoleReplyInfo object
@@ -1501,7 +1534,7 @@
                 OFRoleReply rrmsg) throws SwitchStateException {
             OFControllerRole cr = rrmsg.getRole();
             Role role = null;
-            switch(cr) {
+            switch (cr) {
             case ROLE_EQUAL:
                 role = Role.EQUAL;
                 break;
@@ -1524,10 +1557,11 @@
         /**
          * Handles all pending port status messages before a switch is declared
          * activated in MASTER or EQUAL role. Note that since this handling
-         * precedes the activation (and therefore notification to IOFSwitchListerners)
-         * the changes to ports will already be visible once the switch is
-         * activated. As a result, no notifications are sent out for these
-         * pending portStatus messages.
+         * precedes the activation (and therefore notification to
+         * IOFSwitchListerners) the changes to ports will already be visible
+         * once the switch is activated. As a result, no notifications are sent
+         * out for these pending portStatus messages.
+         * 
          * @param h
          * @throws SwitchStateException
          */
@@ -1546,8 +1580,8 @@
                         "happen";
                 throw new SwitchStateException(msg);
             }
-            ArrayList<OFPortStatus> temp  = new ArrayList<OFPortStatus>();
-            for (OFPortStatus ps: h.pendingPortStatusMsg) {
+            ArrayList<OFPortStatus> temp = new ArrayList<OFPortStatus>();
+            for (OFPortStatus ps : h.pendingPortStatusMsg) {
                 temp.add(ps);
                 handlePortStatusMessage(h, ps, false);
             }
@@ -1555,9 +1589,12 @@
             // expensive but ok - we don't expect too many port-status messages
             // note that we cannot use clear(), because of the reasons below
             h.pendingPortStatusMsg.removeAll(temp);
-            // the iterator above takes a snapshot of the list - so while we were
-            // dealing with the pending port-status messages, we could have received
-            // newer ones. Handle them recursively, but break the recursion after
+            // the iterator above takes a snapshot of the list - so while we
+            // were
+            // dealing with the pending port-status messages, we could have
+            // received
+            // newer ones. Handle them recursively, but break the recursion
+            // after
             // five steps to avoid an attack.
             if (!h.pendingPortStatusMsg.isEmpty() && ++index < 5) {
                 handlePendingPortStatusMessages(h, index);
@@ -1566,30 +1603,29 @@
 
         /**
          * Handle a port status message.
-         *
+         * 
          * Handle a port status message by updating the port maps in the
-         * IOFSwitch instance and notifying Controller about the change so
-         * it can dispatch a switch update.
-         *
+         * IOFSwitch instance and notifying Controller about the change so it
+         * can dispatch a switch update.
+         * 
          * @param h The OFChannelHhandler that received the message
          * @param m The PortStatus message we received
-         * @param doNotify if true switch port changed events will be
-         * dispatched
+         * @param doNotify if true switch port changed events will be dispatched
          * @throws SwitchStateException
-         *
+         * 
          */
         protected void handlePortStatusMessage(OFChannelHandler h, OFPortStatus m,
                 boolean doNotify) throws SwitchStateException {
             if (h.sw == null) {
                 String msg = getSwitchStateMessage(h, m,
                         "State machine error: switch is null. Should never " +
-                        "happen");
+                                "happen");
                 throw new SwitchStateException(msg);
             }
 
             Collection<PortChangeEvent> changes = h.sw.processOFPortStatus(m);
             if (doNotify) {
-                for (PortChangeEvent ev: changes)
+                for (PortChangeEvent ev : changes)
                     h.controller.notifyPortChanged(h.sw.getId(), ev.port, ev.type);
             }
         }
@@ -1597,56 +1633,56 @@
         /**
          * Checks if the role received (from the role-reply msg) is different
          * from the existing role in the IOFSwitch object for this controller.
-         * If so, it transitions the controller to the new role. Note that
-         * the caller should have already verified that the role-reply msg
-         * received was in response to a role-request msg sent out by this
-         * controller after hearing from the registry service.
-         *
+         * If so, it transitions the controller to the new role. Note that the
+         * caller should have already verified that the role-reply msg received
+         * was in response to a role-request msg sent out by this controller
+         * after hearing from the registry service.
+         * 
          * @param h the ChannelHandler that received the message
          * @param role the role in the recieved role reply message
          */
         protected void checkAndSetRoleTransition(OFChannelHandler h, Role role) {
-		// we received a role-reply in response to a role message
-		// sent after hearing from the registry service. It is
-		// possible that the role of this controller instance for
-		// this switch has changed:
-		// for 1.0 switch: from MASTER to SLAVE
-		// for 1.3 switch: from MASTER to EQUAL
-		if ((h.sw.getRole() == Role.MASTER && role == Role.SLAVE) ||
-			(h.sw.getRole() == Role.MASTER && role == Role.EQUAL)) {
-			// the mastership has changed
-			h.sw.setRole(role);
-			h.setState(EQUAL);
-			h.controller.transitionToEqualSwitch(h.sw.getId());
-			return;
-		}
+            // we received a role-reply in response to a role message
+            // sent after hearing from the registry service. It is
+            // possible that the role of this controller instance for
+            // this switch has changed:
+            // for 1.0 switch: from MASTER to SLAVE
+            // for 1.3 switch: from MASTER to EQUAL
+            if ((h.sw.getRole() == Role.MASTER && role == Role.SLAVE) ||
+                    (h.sw.getRole() == Role.MASTER && role == Role.EQUAL)) {
+                // the mastership has changed
+                h.sw.setRole(role);
+                h.setState(EQUAL);
+                h.controller.transitionToEqualSwitch(h.sw.getId());
+                return;
+            }
 
-		// or for both 1.0 and 1.3 switches from EQUAL to MASTER.
-		// note that for 1.0, even though we mean SLAVE,
-		// internally we call the role EQUAL.
-		if (h.sw.getRole() == Role.EQUAL && role == Role.MASTER) {
-			// the mastership has changed
-			h.sw.setRole(role);
-			h.setState(MASTER);
-			h.controller.transitionToMasterSwitch(h.sw.getId());
-			return;
-		}
+            // or for both 1.0 and 1.3 switches from EQUAL to MASTER.
+            // note that for 1.0, even though we mean SLAVE,
+            // internally we call the role EQUAL.
+            if (h.sw.getRole() == Role.EQUAL && role == Role.MASTER) {
+                // the mastership has changed
+                h.sw.setRole(role);
+                h.setState(MASTER);
+                h.controller.transitionToMasterSwitch(h.sw.getId());
+                return;
+            }
         }
 
         /**
-         * Process an OF message received on the channel and
-         * update state accordingly.
-         *
+         * Process an OF message received on the channel and update state
+         * accordingly.
+         * 
          * The main "event" of the state machine. Process the received message,
          * send follow up message if required and update state if required.
-         *
+         * 
          * Switches on the message type and calls more specific event handlers
-         * for each individual OF message type. If we receive a message that
-         * is supposed to be sent from a controller to a switch we throw
-         * a SwitchStateExeption.
-         *
+         * for each individual OF message type. If we receive a message that is
+         * supposed to be sent from a controller to a switch we throw a
+         * SwitchStateExeption.
+         * 
          * The more specific handlers can also throw SwitchStateExceptions
-         *
+         * 
          * @param h The OFChannelHandler that received the message
          * @param m The message we received.
          * @throws SwitchStateException
@@ -1655,72 +1691,72 @@
         void processOFMessage(OFChannelHandler h, OFMessage m)
                 throws IOException, SwitchStateException {
             h.roleChanger.checkTimeout();
-            switch(m.getType()) {
-                case HELLO:
-                    processOFHello(h, (OFHello)m);
-                    break;
-                case BARRIER_REPLY:
-                    processOFBarrierReply(h, (OFBarrierReply)m);
-                    break;
-                case ECHO_REPLY:
-                    processOFEchoReply(h, (OFEchoReply)m);
-                    break;
-                case ECHO_REQUEST:
-                    processOFEchoRequest(h, (OFEchoRequest)m);
-                    break;
-                case ERROR:
-                    processOFError(h, (OFErrorMsg)m);
-                    break;
-                case FEATURES_REPLY:
-                    processOFFeaturesReply(h, (OFFeaturesReply)m);
-                    break;
-                case FLOW_REMOVED:
-                    processOFFlowRemoved(h, (OFFlowRemoved)m);
-                    break;
-                case GET_CONFIG_REPLY:
-                    processOFGetConfigReply(h, (OFGetConfigReply)m);
-                    break;
-                case PACKET_IN:
-                    processOFPacketIn(h, (OFPacketIn)m);
-                    break;
-                case PORT_STATUS:
-                    processOFPortStatus(h, (OFPortStatus)m);
-                    break;
-                case QUEUE_GET_CONFIG_REPLY:
-                    processOFQueueGetConfigReply(h, (OFQueueGetConfigReply)m);
-                    break;
-                case STATS_REPLY: // multipart_reply in 1.3
-                    processOFStatisticsReply(h, (OFStatsReply)m);
-                    break;
-                case EXPERIMENTER:
-                    processOFExperimenter(h, (OFExperimenter)m);
-                    break;
-                case ROLE_REPLY:
-                    processOFRoleReply(h, (OFRoleReply)m);
-                    break;
-                case GET_ASYNC_REPLY:
-                    processOFGetAsyncReply(h, (OFAsyncGetReply)m);
-                    break;
+            switch (m.getType()) {
+            case HELLO:
+                processOFHello(h, (OFHello) m);
+                break;
+            case BARRIER_REPLY:
+                processOFBarrierReply(h, (OFBarrierReply) m);
+                break;
+            case ECHO_REPLY:
+                processOFEchoReply(h, (OFEchoReply) m);
+                break;
+            case ECHO_REQUEST:
+                processOFEchoRequest(h, (OFEchoRequest) m);
+                break;
+            case ERROR:
+                processOFError(h, (OFErrorMsg) m);
+                break;
+            case FEATURES_REPLY:
+                processOFFeaturesReply(h, (OFFeaturesReply) m);
+                break;
+            case FLOW_REMOVED:
+                processOFFlowRemoved(h, (OFFlowRemoved) m);
+                break;
+            case GET_CONFIG_REPLY:
+                processOFGetConfigReply(h, (OFGetConfigReply) m);
+                break;
+            case PACKET_IN:
+                processOFPacketIn(h, (OFPacketIn) m);
+                break;
+            case PORT_STATUS:
+                processOFPortStatus(h, (OFPortStatus) m);
+                break;
+            case QUEUE_GET_CONFIG_REPLY:
+                processOFQueueGetConfigReply(h, (OFQueueGetConfigReply) m);
+                break;
+            case STATS_REPLY: // multipart_reply in 1.3
+                processOFStatisticsReply(h, (OFStatsReply) m);
+                break;
+            case EXPERIMENTER:
+                processOFExperimenter(h, (OFExperimenter) m);
+                break;
+            case ROLE_REPLY:
+                processOFRoleReply(h, (OFRoleReply) m);
+                break;
+            case GET_ASYNC_REPLY:
+                processOFGetAsyncReply(h, (OFAsyncGetReply) m);
+                break;
 
-                // The following messages are sent to switches. The controller
-                // should never receive them
-                case SET_CONFIG:
-                case GET_CONFIG_REQUEST:
-                case PACKET_OUT:
-                case PORT_MOD:
-                case QUEUE_GET_CONFIG_REQUEST:
-                case BARRIER_REQUEST:
-                case STATS_REQUEST: // multipart request in 1.3
-                case FEATURES_REQUEST:
-                case FLOW_MOD:
-                case GROUP_MOD:
-                case TABLE_MOD:
-                case GET_ASYNC_REQUEST:
-                case SET_ASYNC:
-                case METER_MOD:
-                default:
-                    illegalMessageReceived(h, m);
-                    break;
+            // The following messages are sent to switches. The controller
+            // should never receive them
+            case SET_CONFIG:
+            case GET_CONFIG_REQUEST:
+            case PACKET_OUT:
+            case PORT_MOD:
+            case QUEUE_GET_CONFIG_REQUEST:
+            case BARRIER_REQUEST:
+            case STATS_REQUEST: // multipart request in 1.3
+            case FEATURES_REQUEST:
+            case FLOW_MOD:
+            case GROUP_MOD:
+            case TABLE_MOD:
+            case GET_ASYNC_REQUEST:
+            case SET_ASYNC:
+            case METER_MOD:
+            default:
+                illegalMessageReceived(h, m);
+                break;
             }
         }
 
@@ -1750,7 +1786,7 @@
         }
 
         void processOFEchoRequest(OFChannelHandler h, OFEchoRequest m)
-            throws IOException {
+                throws IOException {
             if (h.ofVersion == null) {
                 log.error("No OF version set for {}. Not sending Echo REPLY",
                         h.channel.getRemoteAddress());
@@ -1766,7 +1802,7 @@
         }
 
         void processOFEchoReply(OFChannelHandler h, OFEchoReply m)
-            throws IOException {
+                throws IOException {
             // Do nothing with EchoReplies !!
         }
 
@@ -1775,14 +1811,13 @@
         abstract void processOFError(OFChannelHandler h, OFErrorMsg m)
                 throws IOException, SwitchStateException;
 
-
-        void processOFFeaturesReply(OFChannelHandler h, OFFeaturesReply  m)
+        void processOFFeaturesReply(OFChannelHandler h, OFFeaturesReply m)
                 throws IOException, SwitchStateException {
             unhandledMessageReceived(h, m);
         }
 
         void processOFFlowRemoved(OFChannelHandler h, OFFlowRemoved m)
-            throws IOException {
+                throws IOException {
             unhandledMessageReceived(h, m);
         }
 
@@ -1802,7 +1837,7 @@
                 throws IOException, SwitchStateException;
 
         void processOFQueueGetConfigReply(OFChannelHandler h,
-                                          OFQueueGetConfigReply m)
+                OFQueueGetConfigReply m)
                 throws IOException {
             unhandledMessageReceived(h, m);
         }
@@ -1831,8 +1866,8 @@
         }
 
         void handleUnsentRoleMessage(OFChannelHandler h, Role role,
-			RoleRecvStatus expectation) throws IOException {
-		// do nothing in most states
+                RoleRecvStatus expectation) throws IOException {
+            // do nothing in most states
         }
 
         /**
@@ -1841,7 +1876,7 @@
          * Role request messages that don't get role-replies (or errors related
          * to the request) time out after DEFAULT_ROLE_TIMEOUT_MS secs, at which
          * time the controller state-machine disconnects the switch
-         *
+         * 
          * @param h the channel handler for this switch
          * @param pendingRole the role for which no reply was received
          * @throws SwitchStateException
@@ -1855,114 +1890,116 @@
         }
     }
 
-
-
-    //*************************
-    //  Channel handler methods
-    //*************************
+    // *************************
+    // Channel handler methods
+    // *************************
 
     @Override
-    @LogMessageDoc(message="New switch connection from {ip address}",
-                   explanation="A new switch has connected from the " +
-                            "specified IP address")
+    @LogMessageDoc(message = "New switch connection from {ip address}",
+            explanation = "A new switch has connected from the " +
+                    "specified IP address")
     public void channelConnected(ChannelHandlerContext ctx,
-                                 ChannelStateEvent e) throws Exception {
+            ChannelStateEvent e) throws Exception {
         counters.switchConnected.updateCounterWithFlush();
         channel = e.getChannel();
         log.info("New switch connection from {}",
-                 channel.getRemoteAddress());
+                channel.getRemoteAddress());
         sendHandshakeHelloMessage();
         setState(ChannelState.WAIT_HELLO);
     }
 
     @Override
-    @LogMessageDoc(message="Disconnected switch {switch information}",
-                   explanation="The specified switch has disconnected.")
+    @LogMessageDoc(message = "Disconnected switch {switch information}",
+            explanation = "The specified switch has disconnected.")
     public void channelDisconnected(ChannelHandlerContext ctx,
-                                    ChannelStateEvent e) throws Exception {
+            ChannelStateEvent e) throws Exception {
         log.info("Switch disconnected callback for sw:{}. Cleaning up ...",
-        		getSwitchInfoString());
+                getSwitchInfoString());
         if (thisdpid != 0) {
-        	if (duplicateDpidFound != Boolean.TRUE) {
-        		// if the disconnected switch (on this ChannelHandler)
-        		// was not one with a duplicate-dpid, it is safe to remove all
-        		// state for it at the controller. Notice that if the disconnected
-        		// switch was a duplicate-dpid, calling the method below would clear
-        		// all state for the original switch (with the same dpid),
-        		// which we obviously don't want.
-        		controller.removeConnectedSwitch(thisdpid);
-        	} else {
-        		// A duplicate was disconnected on this ChannelHandler,
-        		// this is the same switch reconnecting, but the original state was
-        		// not cleaned up - XXX check liveness of original ChannelHandler
-        		duplicateDpidFound = Boolean.FALSE;
-        	}
+            if (duplicateDpidFound != Boolean.TRUE) {
+                // if the disconnected switch (on this ChannelHandler)
+                // was not one with a duplicate-dpid, it is safe to remove all
+                // state for it at the controller. Notice that if the
+                // disconnected
+                // switch was a duplicate-dpid, calling the method below would
+                // clear
+                // all state for the original switch (with the same dpid),
+                // which we obviously don't want.
+                controller.removeConnectedSwitch(thisdpid);
+            } else {
+                // A duplicate was disconnected on this ChannelHandler,
+                // this is the same switch reconnecting, but the original state
+                // was
+                // not cleaned up - XXX check liveness of original
+                // ChannelHandler
+                duplicateDpidFound = Boolean.FALSE;
+            }
         } else {
-        	log.warn("no dpid in channelHandler registered for "
-        			+ "disconnected switch {}", getSwitchInfoString());
+            log.warn("no dpid in channelHandler registered for "
+                    + "disconnected switch {}", getSwitchInfoString());
         }
     }
 
     @Override
     @LogMessageDocs({
-        @LogMessageDoc(level="ERROR",
-                message="Disconnecting switch {switch} due to read timeout",
-                explanation="The connected switch has failed to send any " +
+            @LogMessageDoc(level = "ERROR",
+                    message = "Disconnecting switch {switch} due to read timeout",
+                    explanation = "The connected switch has failed to send any " +
                             "messages or respond to echo requests",
-                recommendation=LogMessageDoc.CHECK_SWITCH),
-        @LogMessageDoc(level="ERROR",
-                message="Disconnecting switch {switch}: failed to " +
-                        "complete handshake",
-                explanation="The switch did not respond correctly " +
+                    recommendation = LogMessageDoc.CHECK_SWITCH),
+            @LogMessageDoc(level = "ERROR",
+                    message = "Disconnecting switch {switch}: failed to " +
+                            "complete handshake",
+                    explanation = "The switch did not respond correctly " +
                             "to handshake messages",
-                recommendation=LogMessageDoc.CHECK_SWITCH),
-        @LogMessageDoc(level="ERROR",
-                message="Disconnecting switch {switch} due to IO Error: {}",
-                explanation="There was an error communicating with the switch",
-                recommendation=LogMessageDoc.CHECK_SWITCH),
-        @LogMessageDoc(level="ERROR",
-                message="Disconnecting switch {switch} due to switch " +
-                        "state error: {error}",
-                explanation="The switch sent an unexpected message",
-                recommendation=LogMessageDoc.CHECK_SWITCH),
-        @LogMessageDoc(level="ERROR",
-                message="Disconnecting switch {switch} due to " +
-                        "message parse failure",
-                explanation="Could not parse a message from the switch",
-                recommendation=LogMessageDoc.CHECK_SWITCH),
-        @LogMessageDoc(level="ERROR",
-                message="Terminating controller due to storage exception",
-                explanation=Controller.ERROR_DATABASE,
-                recommendation=LogMessageDoc.CHECK_CONTROLLER),
-        @LogMessageDoc(level="ERROR",
-                message="Could not process message: queue full",
-                explanation="OpenFlow messages are arriving faster than " +
+                    recommendation = LogMessageDoc.CHECK_SWITCH),
+            @LogMessageDoc(level = "ERROR",
+                    message = "Disconnecting switch {switch} due to IO Error: {}",
+                    explanation = "There was an error communicating with the switch",
+                    recommendation = LogMessageDoc.CHECK_SWITCH),
+            @LogMessageDoc(level = "ERROR",
+                    message = "Disconnecting switch {switch} due to switch " +
+                            "state error: {error}",
+                    explanation = "The switch sent an unexpected message",
+                    recommendation = LogMessageDoc.CHECK_SWITCH),
+            @LogMessageDoc(level = "ERROR",
+                    message = "Disconnecting switch {switch} due to " +
+                            "message parse failure",
+                    explanation = "Could not parse a message from the switch",
+                    recommendation = LogMessageDoc.CHECK_SWITCH),
+            @LogMessageDoc(level = "ERROR",
+                    message = "Terminating controller due to storage exception",
+                    explanation = Controller.ERROR_DATABASE,
+                    recommendation = LogMessageDoc.CHECK_CONTROLLER),
+            @LogMessageDoc(level = "ERROR",
+                    message = "Could not process message: queue full",
+                    explanation = "OpenFlow messages are arriving faster than " +
                             " the controller can process them.",
-                recommendation=LogMessageDoc.CHECK_CONTROLLER),
-        @LogMessageDoc(level="ERROR",
-                message="Error while processing message " +
-                        "from switch {switch} {cause}",
-                explanation="An error occurred processing the switch message",
-                recommendation=LogMessageDoc.GENERIC_ACTION)
+                    recommendation = LogMessageDoc.CHECK_CONTROLLER),
+            @LogMessageDoc(level = "ERROR",
+                    message = "Error while processing message " +
+                            "from switch {switch} {cause}",
+                    explanation = "An error occurred processing the switch message",
+                    recommendation = LogMessageDoc.GENERIC_ACTION)
     })
     public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
             throws Exception {
         if (e.getCause() instanceof ReadTimeoutException) {
             // switch timeout
             log.error("Disconnecting switch {} due to read timeout",
-                                 getSwitchInfoString());
+                    getSwitchInfoString());
             counters.switchDisconnectReadTimeout.updateCounterWithFlush();
             ctx.getChannel().close();
         } else if (e.getCause() instanceof HandshakeTimeoutException) {
             log.error("Disconnecting switch {}: failed to complete handshake",
-                      getSwitchInfoString());
+                    getSwitchInfoString());
             counters.switchDisconnectHandshakeTimeout.updateCounterWithFlush();
             ctx.getChannel().close();
         } else if (e.getCause() instanceof ClosedChannelException) {
             log.debug("Channel for sw {} already closed", getSwitchInfoString());
         } else if (e.getCause() instanceof IOException) {
             log.error("Disconnecting switch {} due to IO Error: {}",
-                      getSwitchInfoString(), e.getCause().getMessage());
+                    getSwitchInfoString(), e.getCause().getMessage());
             if (log.isDebugEnabled()) {
                 // still print stack trace if debug is enabled
                 log.debug("StackTrace for previous Exception: ", e.getCause());
@@ -1971,7 +2008,7 @@
             ctx.getChannel().close();
         } else if (e.getCause() instanceof SwitchStateException) {
             log.error("Disconnecting switch {} due to switch state error: {}",
-                      getSwitchInfoString(), e.getCause().getMessage());
+                    getSwitchInfoString(), e.getCause().getMessage());
             if (log.isDebugEnabled()) {
                 // still print stack trace if debug is enabled
                 log.debug("StackTrace for previous Exception: ", e.getCause());
@@ -1980,9 +2017,9 @@
             ctx.getChannel().close();
         } else if (e.getCause() instanceof OFParseError) {
             log.error("Disconnecting switch "
-                                 + getSwitchInfoString() +
-                                 " due to message parse failure",
-                                 e.getCause());
+                    + getSwitchInfoString() +
+                    " due to message parse failure",
+                    e.getCause());
             counters.switchDisconnectParseError.updateCounterWithFlush();
             ctx.getChannel().close();
         } else if (e.getCause() instanceof RejectedExecutionException) {
@@ -1990,8 +2027,8 @@
             counters.rejectedExecutionException.updateCounterWithFlush();
         } else {
             log.error("Error while processing message from switch "
-                                 + getSwitchInfoString()
-                                 + "state " + this.state, e.getCause());
+                    + getSwitchInfoString()
+                    + "state " + this.state, e.getCause());
             counters.switchDisconnectOtherException.updateCounterWithFlush();
             ctx.getChannel().close();
         }
@@ -2019,7 +2056,7 @@
             throws Exception {
         if (e.getMessage() instanceof List) {
             @SuppressWarnings("unchecked")
-            List<OFMessage> msglist = (List<OFMessage>)e.getMessage();
+            List<OFMessage> msglist = (List<OFMessage>) e.getMessage();
 
             LoadMonitor.LoadLevel loadlevel;
             int packets_dropped = 0;
@@ -2035,14 +2072,15 @@
 
             for (OFMessage ofm : msglist) {
                 counters.messageReceived.updateCounterNoFlush();
-                // Per-switch input throttling - placeholder for future throttling
+                // Per-switch input throttling - placeholder for future
+                // throttling
                 /*if (sw != null && sw.inputThrottled(ofm)) {
                     counters.messageInputThrottled.updateCounterNoFlush();
                     continue;
                 }*/
                 try {
                     if (this.controller.overload_drop &&
-                        !loadlevel.equals(LoadMonitor.LoadLevel.OK)) {
+                            !loadlevel.equals(LoadMonitor.LoadLevel.OK)) {
                         switch (ofm.getType()) {
                         case PACKET_IN:
                             switch (loadlevel) {
@@ -2052,12 +2090,12 @@
                                 continue;
                             case HIGH:
                                 // Drop all packet-ins, except LLDP/BDDPs
-                                byte[] data = ((OFPacketIn)ofm).getData();
+                                byte[] data = ((OFPacketIn) ofm).getData();
                                 if (data.length > 14) {
-                                    if (((data[12] == (byte)0x88) &&
-                                         (data[13] == (byte)0xcc)) ||
-                                        ((data[12] == (byte)0x89) &&
-                                         (data[13] == (byte)0x42))) {
+                                    if (((data[12] == (byte) 0x88) &&
+                                            (data[13] == (byte) 0xcc)) ||
+                                            ((data[12] == (byte) 0x89) &&
+                                            (data[13] == (byte) 0x42))) {
                                         lldps_allowed++;
                                         packets_allowed++;
                                         break;
@@ -2081,8 +2119,7 @@
                     // Do the actual packet processing
                     state.processOFMessage(this, ofm);
 
-                }
-                catch (Exception ex) {
+                } catch (Exception ex) {
                     // We are the last handler in the stream, so run the
                     // exception through the channel again by passing in
                     // ctx.getChannel().
@@ -2093,18 +2130,19 @@
             if (loadlevel != LoadMonitor.LoadLevel.OK) {
                 if (log.isDebugEnabled()) {
                     log.debug(
-                        "Overload: Detected {}, packets dropped={}",
-                        loadlevel.toString(), packets_dropped);
+                            "Overload: Detected {}, packets dropped={}",
+                            loadlevel.toString(), packets_dropped);
                     log.debug(
-                        "Overload: Packets allowed={} (LLDP/BDDPs allowed={})",
-                        packets_allowed, lldps_allowed);
+                            "Overload: Packets allowed={} (LLDP/BDDPs allowed={})",
+                            packets_allowed, lldps_allowed);
                 }
             }
         }
         else {
-            //Channels.fireExceptionCaught(ctx.getChannel(),
-            //      new AssertionError("Message received from Channel is not a list"));
-            //TODO: Pankaj: move the counters using ONOS metrics implementation
+            // Channels.fireExceptionCaught(ctx.getChannel(),
+            // new
+            // AssertionError("Message received from Channel is not a list"));
+            // TODO: Pankaj: move the counters using ONOS metrics implementation
 
             counters.messageReceived.updateCounterNoFlush();
             state.processOFMessage(this, (OFMessage) e.getMessage());
@@ -2115,14 +2153,13 @@
         this.controller.flushAll();
     }
 
-
-
-    //*************************
-    //  Channel utility methods
-    //*************************
+    // *************************
+    // Channel utility methods
+    // *************************
 
     /**
      * Is this a state in which the handshake has completed?
+     * 
      * @return true if the handshake is complete
      */
     public boolean isHandshakeComplete() {
@@ -2137,6 +2174,7 @@
     /**
      * Return a string describing this switch based on the already available
      * information (DPID and/or remote socket)
+     * 
      * @return
      */
     private String getSwitchInfoString() {
@@ -2158,8 +2196,9 @@
     }
 
     /**
-     * Update the channels state. Only called from the state machine.
-     * TODO: enforce restricted state transitions
+     * Update the channels state. Only called from the state machine. TODO:
+     * enforce restricted state transitions
+     * 
      * @param state
      */
     private void setState(ChannelState state) {
@@ -2168,13 +2207,16 @@
 
     /**
      * Send hello message to the switch using the handshake transactions ids.
+     * 
      * @throws IOException
      */
     private void sendHandshakeHelloMessage() throws IOException {
-        // The OF protocol requires us to start things off by sending the highest
+        // The OF protocol requires us to start things off by sending the
+        // highest
         // version of the protocol supported.
 
-        // bitmap represents OF1.0 (ofp_version=0x01) and OF1.3 (ofp_version=0x04)
+        // bitmap represents OF1.0 (ofp_version=0x01) and OF1.3
+        // (ofp_version=0x04)
         // see Sec. 7.5.1 of the OF1.3.4 spec
         U32 bitmap = U32.ofRaw(0x00000012);
         OFHelloElem hem = factory13.buildHelloElemVersionbitmap()
@@ -2188,7 +2230,9 @@
     }
 
     /**
-     * Send featuresRequest msg to the switch using the handshake transactions ids.
+     * Send featuresRequest msg to the switch using the handshake transactions
+     * ids.
+     * 
      * @throws IOException
      */
     private void sendHandshakeFeaturesRequestMessage() throws IOException {
@@ -2204,13 +2248,14 @@
     }
 
     /**
-     * Send the configuration requests to tell the switch we want full
-     * packets
+     * Send the configuration requests to tell the switch we want full packets
+     * 
      * @throws IOException
      */
     private void sendHandshakeSetConfig() throws IOException {
         OFFactory factory = (ofVersion == OFVersion.OF_13) ? factory13 : factory10;
-        //log.debug("Sending CONFIG_REQUEST to {}", channel.getRemoteAddress());
+        // log.debug("Sending CONFIG_REQUEST to {}",
+        // channel.getRemoteAddress());
         List<OFMessage> msglist = new ArrayList<OFMessage>(3);
 
         // Ensure we receive the full packet via PacketIn
@@ -2240,6 +2285,7 @@
 
     /**
      * send a description state request
+     * 
      * @throws IOException
      */
     private void sendHandshakeDescriptionStatsRequest() throws IOException {
@@ -2276,5 +2322,4 @@
         roleChanger = new RoleChanger(roleTimeoutMs);
     }
 
-
 }
diff --git a/src/main/java/net/floodlightcontroller/core/internal/OFSwitchImplBase.java b/src/main/java/net/floodlightcontroller/core/internal/OFSwitchImplBase.java
index 6fe5cc9..c51875f 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/OFSwitchImplBase.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/OFSwitchImplBase.java
@@ -84,7 +84,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
 /**
  * This is the internal representation of an openflow switch.
  */
@@ -120,27 +119,28 @@
     // Lock to protect modification of the port maps. We only need to
     // synchronize on modifications. For read operations we are fine since
     // we rely on ConcurrentMaps which works for our use case.
-    //private Object portLock; XXX S remove this
+    // private Object portLock; XXX S remove this
 
     // Map port numbers to the appropriate OFPortDesc
     protected ConcurrentHashMap<Integer, OFPortDesc> portsByNumber;
     // Map port names to the appropriate OFPhyiscalPort
     // XXX: The OF spec doesn't specify if port names need to be unique but
-    //      according it's always the case in practice.
+    // according it's always the case in practice.
     protected ConcurrentHashMap<String, OFPortDesc> portsByName;
     protected Map<Integer, OFStatisticsFuture> statsFutureMap;
-    protected Map<Integer, IOFMessageListener> iofMsgListenersMap; // XXX S why is this needed?
+    // XXX Consider removing the following 2 maps - not used anymore
+    protected Map<Integer, IOFMessageListener> iofMsgListenersMap;
     protected Map<Integer, OFFeaturesReplyFuture> featuresFutureMap;
     protected boolean connected;
     protected Role role;
     protected ReentrantReadWriteLock listenerLock;
     protected ConcurrentMap<Short, Long> portBroadcastCacheHitMap;
     /**
-     * When sending a role request message, the role request is added
-     * to this queue. If a role reply is received this queue is checked to
-     * verify that the reply matches the expected reply. We require in order
-     * delivery of replies. That's why we use a Queue.
-     * The RoleChanger uses a timeout to ensure we receive a timely reply.
+     * When sending a role request message, the role request is added to this
+     * queue. If a role reply is received this queue is checked to verify that
+     * the reply matches the expected reply. We require in order delivery of
+     * replies. That's why we use a Queue. The RoleChanger uses a timeout to
+     * ensure we receive a timely reply.
      * <p/>
      * Need to synchronize on this instance if a request is sent, received,
      * checked.
@@ -157,31 +157,28 @@
     protected Set<OFActionType> actions;
     protected byte tables;
     protected DatapathId datapathId;
-	private OFAuxId auxId;
+    private OFAuxId auxId;
 
     private IDebugCounterService debugCounters;
-	private boolean debugCountersRegistered;
-	@SuppressWarnings("unused")
+    private boolean debugCountersRegistered;
+    @SuppressWarnings("unused")
     private IDebugCounter ctrSwitch, ctrSwitchPktin, ctrSwitchWrite,
-    ctrSwitchPktinDrops, ctrSwitchWriteDrops;
+            ctrSwitchPktinDrops, ctrSwitchWriteDrops;
 
-	protected boolean startDriverHandshakeCalled = false;
-	private boolean flowTableFull = false;
+    protected boolean startDriverHandshakeCalled = false;
+    private boolean flowTableFull = false;
 
-	private final PortManager portManager;
-
-
+    private final PortManager portManager;
 
     protected static final ThreadLocal<Map<OFSwitchImplBase, List<OFMessage>>> local_msg_buffer =
-		new ThreadLocal<Map<OFSwitchImplBase, List<OFMessage>>>() {
-	@Override
-	protected Map<OFSwitchImplBase, List<OFMessage>> initialValue() {
-		return new WeakHashMap<OFSwitchImplBase, List<OFMessage>>();
-	}
-    };
+            new ThreadLocal<Map<OFSwitchImplBase, List<OFMessage>>>() {
+                @Override
+                protected Map<OFSwitchImplBase, List<OFMessage>> initialValue() {
+                    return new WeakHashMap<OFSwitchImplBase, List<OFMessage>>();
+                }
+            };
 
-
-	private static final String BASE = "switchbase";
+    private static final String BASE = "switchbase";
 
     protected static class PendingRoleRequestEntry {
         protected int xid;
@@ -201,7 +198,8 @@
         this.attributes = new ConcurrentHashMap<Object, Object>();
         this.connectedSince = new Date();
         this.transactionIdSource = new AtomicInteger();
-        this.generationIdSource = 0; // XXX S this is wrong; should be negotiated
+        this.generationIdSource = 0; // XXX S this is wrong; should be
+                                     // negotiated
         // XXX S no need this.portLock = new Object();
         this.portsByNumber = new ConcurrentHashMap<Integer, OFPortDesc>();
         this.portsByName = new ConcurrentHashMap<String, OFPortDesc>();
@@ -220,9 +218,9 @@
 
     }
 
-    //*******************************************
-    //    Setters and Getters
-    //*******************************************
+    // *******************************************
+    // Setters and Getters
+    // *******************************************
 
     @Override
     public Object getAttribute(String name) {
@@ -312,13 +310,12 @@
     @Override
     public String toString() {
         return "OFSwitchImpl [" + ((channel != null) ? channel.getRemoteAddress() : "?")
-			+ " DPID[" + ((stringId != null) ? stringId : "?") + "]]";
+                + " DPID[" + ((stringId != null) ? stringId : "?") + "]]";
     }
 
-
-    //*******************************************
-    //    Channel related methods
-    //*******************************************
+    // *******************************************
+    // Channel related methods
+    // *******************************************
 
     @JsonIgnore
     @Override
@@ -335,7 +332,7 @@
             msg_buffer_map.put(this, msg_buffer);
         }
         // XXX S will change when iFloodlight provider changes
-        //this.floodlightProvider.handleOutgoingMessage(this, m, bc);
+        // this.floodlightProvider.handleOutgoingMessage(this, m, bc);
         msg_buffer.add(m);
 
         if ((msg_buffer.size() >= Controller.BATCH_MAX_SIZE) ||
@@ -353,23 +350,23 @@
                     "that is not valid when the switch is in a slave role",
             recommendation = LogMessageDoc.REPORT_CONTROLLER_BUG)
     public void write(List<OFMessage> msglist,
-                      FloodlightContext bc) throws IOException {
+            FloodlightContext bc) throws IOException {
         for (OFMessage m : msglist) {
             if (role == Role.SLAVE) {
                 switch (m.getType()) {
-                    case PACKET_OUT:
-                    case FLOW_MOD:
-                    case PORT_MOD:
-                        log.warn("Sending OF message that modifies switch " +
-                                "state while in the slave role: {}",
-                                m.getType().name());
-                        break;
-                    default:
-                        break;
+                case PACKET_OUT:
+                case FLOW_MOD:
+                case PORT_MOD:
+                    log.warn("Sending OF message that modifies switch " +
+                            "state while in the slave role: {}",
+                            m.getType().name());
+                    break;
+                default:
+                    break;
                 }
             }
             // XXX S again
-            //this.floodlightProvider.handleOutgoingMessage(this, m, bc);
+            // this.floodlightProvider.handleOutgoingMessage(this, m, bc);
         }
         this.write(msglist);
     }
@@ -406,95 +403,98 @@
         this.connected = connected;
     }
 
-
-
-    //*******************************************
-    //    Switch features related methods
-    //*******************************************
+    // *******************************************
+    // Switch features related methods
+    // *******************************************
 
     /**
      * Set the features reply for this switch from the handshake
      */
     protected void setFeaturesReply(OFFeaturesReply featuresReply) {
-	if (featuresReply == null) {
-		log.error("Error setting featuresReply for switch: {}", getStringId());
-		return;
-	}
-	this.datapathId = featuresReply.getDatapathId();
-	this.capabilities = featuresReply.getCapabilities();
-	this.buffers = (int) featuresReply.getNBuffers();
-	this.tables = (byte) featuresReply.getNTables();
-	this.stringId = this.datapathId.toString();
-	if (ofversion == OFVersion.OF_13) {
-		auxId = featuresReply.getAuxiliaryId();
-		if (!auxId.equals(OFAuxId.MAIN)) {
-			log.warn("This controller does not handle auxiliary connections. "
-					+ "Aux connection id {} received from switch {}",
-					auxId, getStringId());
-		}
-	}
+        if (featuresReply == null) {
+            log.error("Error setting featuresReply for switch: {}", getStringId());
+            return;
+        }
+        this.datapathId = featuresReply.getDatapathId();
+        this.capabilities = featuresReply.getCapabilities();
+        this.buffers = (int) featuresReply.getNBuffers();
+        this.tables = (byte) featuresReply.getNTables();
+        this.stringId = this.datapathId.toString();
+        if (ofversion == OFVersion.OF_13) {
+            auxId = featuresReply.getAuxiliaryId();
+            if (!auxId.equals(OFAuxId.MAIN)) {
+                log.warn("This controller does not handle auxiliary connections. "
+                        + "Aux connection id {} received from switch {}",
+                        auxId, getStringId());
+            }
+        }
 
-	if (ofversion == OFVersion.OF_10) {
-		this.actions = featuresReply.getActions();
-		portManager.compareAndUpdatePorts(featuresReply.getPorts(), true);
-	}
+        if (ofversion == OFVersion.OF_10) {
+            this.actions = featuresReply.getActions();
+            portManager.compareAndUpdatePorts(featuresReply.getPorts(), true);
+        }
     }
 
     /**
-     * Set the port descriptions for this switch from the handshake for
-     * an OF1.3 switch.
+     * Set the port descriptions for this switch from the handshake for an OF1.3
+     * switch.
      */
     protected void setPortDescReply(OFPortDescStatsReply pdrep) {
-	if (ofversion != OFVersion.OF_13) return;
-	if (pdrep == null) {
-		log.error("Error setting ports description for switch: {}", getStringId());
-		return;
-	}
-	portManager.updatePorts(pdrep.getEntries());
+        if (ofversion != OFVersion.OF_13)
+            return;
+        if (pdrep == null) {
+            log.error("Error setting ports description for switch: {}", getStringId());
+            return;
+        }
+        portManager.updatePorts(pdrep.getEntries());
     }
 
     @Override
     public int getNumBuffers() {
         return buffers;
     }
+
     @Override
     public Set<OFActionType> getActions() {
         return actions;
     }
+
     @Override
-    public  Set<OFCapabilities> getCapabilities() {
+    public Set<OFCapabilities> getCapabilities() {
         return capabilities;
     }
+
     @Override
     public byte getNumTables() {
         return tables;
     }
 
-//    public Future<OFFeaturesReply> getFeaturesReplyFromSwitch()
-//            throws IOException {
-//    	// XXX S fix this later
-//    	OFMessage request = floodlightProvider.getOFMessageFactory_13()
-//    			.buildFeaturesRequest()
-//    			.setXid(getNextTransactionId())
-//    			.build();
-//    	OFFeaturesReplyFuture future =
-//                new OFFeaturesReplyFuture(threadPool, this, (int) request.getXid());
-//        this.featuresFutureMap.put((int) request.getXid(), future);
-//        this.channel.write(Collections.singletonList(request));
-//        return future;
-//
-//    }
-//
-//    public void deliverOFFeaturesReply(OFMessage reply) {
-//        OFFeaturesReplyFuture future = this.featuresFutureMap.get(reply.getXid());
-//        if (future != null) {
-//            future.deliverFuture(this, reply);
-//            // The future will ultimately unregister itself and call
-//            // cancelFeaturesReply
-//            return;
-//        }
-//        log.error("Switch {}: received unexpected featureReply", this);
-//    }
+    // public Future<OFFeaturesReply> getFeaturesReplyFromSwitch()
+    // throws IOException {
+    // // XXX S fix this later
+    // OFMessage request = floodlightProvider.getOFMessageFactory_13()
+    // .buildFeaturesRequest()
+    // .setXid(getNextTransactionId())
+    // .build();
+    // OFFeaturesReplyFuture future =
+    // new OFFeaturesReplyFuture(threadPool, this, (int) request.getXid());
+    // this.featuresFutureMap.put((int) request.getXid(), future);
+    // this.channel.write(Collections.singletonList(request));
+    // return future;
+    //
+    // }
+    //
+    // public void deliverOFFeaturesReply(OFMessage reply) {
+    // OFFeaturesReplyFuture future =
+    // this.featuresFutureMap.get(reply.getXid());
+    // if (future != null) {
+    // future.deliverFuture(this, reply);
+    // // The future will ultimately unregister itself and call
+    // // cancelFeaturesReply
+    // return;
+    // }
+    // log.error("Switch {}: received unexpected featureReply", this);
+    // }
 
     @Override
     public void cancelFeaturesReply(int transactionId) {
@@ -503,18 +503,18 @@
 
     @JsonIgnore
     public void setSwitchDescription(OFDescStatsReply desc) {
-	switchDescription = desc;
+        switchDescription = desc;
     }
 
     @Override
     @JsonIgnore
     public OFDescStatsReply getSwitchDescription() {
-	return switchDescription;
+        return switchDescription;
     }
 
-    //*******************************************
-    //    Switch port handling
-    //*******************************************
+    // *******************************************
+    // Switch port handling
+    // *******************************************
 
     @Override
     @JsonIgnore
@@ -547,7 +547,7 @@
     @Override
     @JsonProperty("ports")
     public Collection<OFPortDesc> getPorts() {
-	return portManager.getPorts();
+        return portManager.getPorts();
     }
 
     @Override
@@ -557,14 +557,14 @@
 
     @Override
     public boolean portEnabled(String portName) {
-	return isEnabled(portManager.getPort(portName));
+        return isEnabled(portManager.getPort(portName));
     }
 
     private boolean isEnabled(OFPortDesc p) {
-	return (p != null &&
-			!p.getState().contains(OFPortState.LINK_DOWN) &&
-			!p.getState().contains(OFPortState.BLOCKED) &&
-                !p.getConfig().contains(OFPortConfig.PORT_DOWN));
+        return (p != null &&
+                !p.getState().contains(OFPortState.LINK_DOWN) &&
+                !p.getState().contains(OFPortState.BLOCKED) && !p.getConfig().contains(
+                OFPortConfig.PORT_DOWN));
     }
 
     @Override
@@ -580,37 +580,33 @@
 
     /**
      * Manages the ports of this switch.
-     *
+     * 
      * Provides methods to query and update the stored ports. The class ensures
-     * that every port name and port number is unique. When updating ports
-     * the class checks if port number <-> port name mappings have change due
-     * to the update. If a new port P has number and port that are inconsistent
-     * with the previous mapping(s) the class will delete all previous ports
-     * with name or number of the new port and then add the new port.
-     *
+     * that every port name and port number is unique. When updating ports the
+     * class checks if port number <-> port name mappings have change due to the
+     * update. If a new port P has number and port that are inconsistent with
+     * the previous mapping(s) the class will delete all previous ports with
+     * name or number of the new port and then add the new port.
+     * 
      * Port names are stored as-is but they are compared case-insensitive
-     *
+     * 
      * The methods that change the stored ports return a list of
-     * PortChangeEvents that represent the changes that have been applied
-     * to the port list so that IOFSwitchListeners can be notified about the
-     * changes.
-     *
-     * Implementation notes:
-     * - We keep several different representations of the ports to allow for
-     *   fast lookups
-     * - Ports are stored in unchangeable lists. When a port is modified new
-     *   data structures are allocated.
-     * - We use a read-write-lock for synchronization, so multiple readers are
-     *   allowed.
-     * - All port numbers have int representation (no more shorts)
+     * PortChangeEvents that represent the changes that have been applied to the
+     * port list so that IOFSwitchListeners can be notified about the changes.
+     * 
+     * Implementation notes: - We keep several different representations of the
+     * ports to allow for fast lookups - Ports are stored in unchangeable lists.
+     * When a port is modified new data structures are allocated. - We use a
+     * read-write-lock for synchronization, so multiple readers are allowed. -
+     * All port numbers have int representation (no more shorts)
      */
     protected class PortManager {
         private final ReentrantReadWriteLock lock;
         private List<OFPortDesc> portList;
         private List<OFPortDesc> enabledPortList;
         private List<Integer> enabledPortNumbers;
-        private Map<Integer,OFPortDesc> portsByNumber;
-        private Map<String,OFPortDesc> portsByName;
+        private Map<Integer, OFPortDesc> portsByNumber;
+        private Map<String, OFPortDesc> portsByName;
 
         public PortManager() {
             this.lock = new ReentrantReadWriteLock();
@@ -622,22 +618,22 @@
         }
 
         /**
-         * Set the internal data structure storing this switch's port
-         * to the ports specified by newPortsByNumber
-         *
+         * Set the internal data structure storing this switch's port to the
+         * ports specified by newPortsByNumber
+         * 
          * CALLER MUST HOLD WRITELOCK
-         *
+         * 
          * @param newPortsByNumber
          * @throws IllegaalStateException if called without holding the
-         * writelock
+         *         writelock
          */
         private void updatePortsWithNewPortsByNumber(
-                Map<Integer,OFPortDesc> newPortsByNumber) {
+                Map<Integer, OFPortDesc> newPortsByNumber) {
             if (!lock.writeLock().isHeldByCurrentThread()) {
                 throw new IllegalStateException("Method called without " +
-                                                "holding writeLock");
+                        "holding writeLock");
             }
-            Map<String,OFPortDesc> newPortsByName =
+            Map<String, OFPortDesc> newPortsByName =
                     new HashMap<String, OFPortDesc>();
             List<OFPortDesc> newPortList =
                     new ArrayList<OFPortDesc>();
@@ -645,7 +641,7 @@
                     new ArrayList<OFPortDesc>();
             List<Integer> newEnabledPortNumbers = new ArrayList<Integer>();
 
-            for(OFPortDesc p: newPortsByNumber.values()) {
+            for (OFPortDesc p : newPortsByNumber.values()) {
                 newPortList.add(p);
                 newPortsByName.put(p.getName().toLowerCase(), p);
                 if (isEnabled(p)) {
@@ -664,27 +660,26 @@
         }
 
         /**
-         * Handle a OFPortStatus delete message for the given port.
-         * Updates the internal port maps/lists of this switch and returns
-         * the PortChangeEvents caused by the delete. If the given port
-         * exists as it, it will be deleted. If the name<->number for the
-         * given port is inconsistent with the ports stored by this switch
-         * the method will delete all ports with the number or name of the
-         * given port.
-         *
+         * Handle a OFPortStatus delete message for the given port. Updates the
+         * internal port maps/lists of this switch and returns the
+         * PortChangeEvents caused by the delete. If the given port exists as
+         * it, it will be deleted. If the name<->number for the given port is
+         * inconsistent with the ports stored by this switch the method will
+         * delete all ports with the number or name of the given port.
+         * 
          * This method will increment error/warn counters and log
-         *
-         * @param delPort the port from the port status message that should
-         * be deleted.
+         * 
+         * @param delPort the port from the port status message that should be
+         *        deleted.
          * @return ordered collection of port changes applied to this switch
          */
         private OrderedCollection<PortChangeEvent> handlePortStatusDelete(
-				OFPortDesc delPort) {
+                OFPortDesc delPort) {
             lock.writeLock().lock();
             OrderedCollection<PortChangeEvent> events =
                     new LinkedHashSetWrapper<PortChangeEvent>();
             try {
-                Map<Integer,OFPortDesc> newPortByNumber =
+                Map<Integer, OFPortDesc> newPortByNumber =
                         new HashMap<Integer, OFPortDesc>(portsByNumber);
                 OFPortDesc prevPort =
                         portsByNumber.get(delPort.getPortNo().getPortNumber());
@@ -694,26 +689,26 @@
                     if (prevPort != null) {
                         newPortByNumber.remove(prevPort.getPortNo().getPortNumber());
                         events.add(new PortChangeEvent(prevPort,
-                                                       PortChangeType.DELETE));
+                                PortChangeType.DELETE));
                     }
                 } else if (prevPort.getName().equals(delPort.getName())) {
                     // port exists with consistent name-number mapping
                     newPortByNumber.remove(delPort.getPortNo().getPortNumber());
                     events.add(new PortChangeEvent(delPort,
-                                                   PortChangeType.DELETE));
+                            PortChangeType.DELETE));
                 } else {
                     // port with same number exists but its name differs. This
                     // is weird. The best we can do is to delete the existing
                     // port(s) that have delPort's name and number.
                     newPortByNumber.remove(delPort.getPortNo().getPortNumber());
                     events.add(new PortChangeEvent(prevPort,
-                                                   PortChangeType.DELETE));
+                            PortChangeType.DELETE));
                     // is there another port that has delPort's name?
                     prevPort = portsByName.get(delPort.getName().toLowerCase());
                     if (prevPort != null) {
                         newPortByNumber.remove(prevPort.getPortNo().getPortNumber());
                         events.add(new PortChangeEvent(prevPort,
-                                                       PortChangeType.DELETE));
+                                PortChangeType.DELETE));
                     }
                 }
                 updatePortsWithNewPortsByNumber(newPortByNumber);
@@ -726,16 +721,16 @@
         /**
          * Handle a OFPortStatus message, update the internal data structures
          * that store ports and return the list of OFChangeEvents.
-         *
+         * 
          * This method will increment error/warn counters and log
-         *
+         * 
          * @param ps
          * @return
          */
         public OrderedCollection<PortChangeEvent> handlePortStatusMessage(OFPortStatus ps) {
             if (ps == null) {
                 throw new NullPointerException("OFPortStatus message must " +
-                                               "not be null");
+                        "not be null");
             }
             lock.writeLock().lock();
             try {
@@ -747,44 +742,44 @@
 
                 if (log.isDebugEnabled()) {
                     log.debug("Handling OFPortStatus: {} for {}",
-                              reason, ps);
+                            reason, ps);
                 }
 
                 if (reason == OFPortReason.DELETE)
-                        return handlePortStatusDelete(ps.getDesc());
+                    return handlePortStatusDelete(ps.getDesc());
 
                 // We handle ADD and MODIFY the same way. Since OpenFlow
                 // doesn't specify what uniquely identifies a port the
                 // notion of ADD vs. MODIFY can also be hazy. So we just
                 // compare the new port to the existing ones.
-                Map<Integer,OFPortDesc> newPortByNumber =
-                    new HashMap<Integer, OFPortDesc>(portsByNumber);
+                Map<Integer, OFPortDesc> newPortByNumber =
+                        new HashMap<Integer, OFPortDesc>(portsByNumber);
                 OrderedCollection<PortChangeEvent> events =
-				getSinglePortChanges(ps.getDesc());
-                for (PortChangeEvent e: events) {
-                    switch(e.type) {
-                        case DELETE:
-                            newPortByNumber.remove(e.port.getPortNo().getPortNumber());
-                            break;
-                        case ADD:
-                            if (reason != OFPortReason.ADD) {
-                                // weird case
-                            }
-                            newPortByNumber.put(e.port.getPortNo().getPortNumber(),
-                                    e.port);
-                            break;
-                        case DOWN:
-                            newPortByNumber.put(e.port.getPortNo().getPortNumber(),
-                                    e.port);
-                            break;
-                        case OTHER_UPDATE:
-                            newPortByNumber.put(e.port.getPortNo().getPortNumber(),
-                                    e.port);
-                            break;
-                        case UP:
-                            newPortByNumber.put(e.port.getPortNo().getPortNumber(),
-					e.port);
-                            break;
+                        getSinglePortChanges(ps.getDesc());
+                for (PortChangeEvent e : events) {
+                    switch (e.type) {
+                    case DELETE:
+                        newPortByNumber.remove(e.port.getPortNo().getPortNumber());
+                        break;
+                    case ADD:
+                        if (reason != OFPortReason.ADD) {
+                            // weird case
+                        }
+                        newPortByNumber.put(e.port.getPortNo().getPortNumber(),
+                                e.port);
+                        break;
+                    case DOWN:
+                        newPortByNumber.put(e.port.getPortNo().getPortNumber(),
+                                e.port);
+                        break;
+                    case OTHER_UPDATE:
+                        newPortByNumber.put(e.port.getPortNo().getPortNumber(),
+                                e.port);
+                        break;
+                    case UP:
+                        newPortByNumber.put(e.port.getPortNo().getPortNumber(),
+                                e.port);
+                        break;
                     }
                 }
                 updatePortsWithNewPortsByNumber(newPortByNumber);
@@ -797,20 +792,20 @@
 
         /**
          * Given a new or modified port newPort, returns the list of
-         * PortChangeEvents to "transform" the current ports stored by
-         * this switch to include / represent the new port. The ports stored
-         * by this switch are <b>NOT</b> updated.
-         *
-         * This method acquires the readlock and is thread-safe by itself.
-         * Most callers will need to acquire the write lock before calling
-         * this method though (if the caller wants to update the ports stored
-         * by this switch)
-         *
+         * PortChangeEvents to "transform" the current ports stored by this
+         * switch to include / represent the new port. The ports stored by this
+         * switch are <b>NOT</b> updated.
+         * 
+         * This method acquires the readlock and is thread-safe by itself. Most
+         * callers will need to acquire the write lock before calling this
+         * method though (if the caller wants to update the ports stored by this
+         * switch)
+         * 
          * @param newPort the new or modified port.
          * @return the list of changes
          */
         public OrderedCollection<PortChangeEvent> getSinglePortChanges(
-			OFPortDesc newPort) {
+                OFPortDesc newPort) {
             lock.readLock().lock();
             try {
                 OrderedCollection<PortChangeEvent> events =
@@ -831,13 +826,13 @@
                     // also matches the new port. Find the differences
                     if (isEnabled(prevPort) && !isEnabled(newPort)) {
                         events.add(new PortChangeEvent(newPort,
-                                                       PortChangeType.DOWN));
+                                PortChangeType.DOWN));
                     } else if (!isEnabled(prevPort) && isEnabled(newPort)) {
                         events.add(new PortChangeEvent(newPort,
-                                                       PortChangeType.UP));
+                                PortChangeType.UP));
                     } else {
                         events.add(new PortChangeEvent(newPort,
-                                   PortChangeType.OTHER_UPDATE));
+                                PortChangeType.OTHER_UPDATE));
                     }
                     return events;
                 }
@@ -848,7 +843,7 @@
                     // never have gotten here)
                     // Remove the port. Name-number mapping(s) have changed
                     events.add(new PortChangeEvent(prevPort,
-                                                   PortChangeType.DELETE));
+                            PortChangeType.DELETE));
                 }
 
                 // We now need to check if there exists a previous port sharing
@@ -860,7 +855,7 @@
                     // never have gotten here).
                     // Remove the port. Name-number mapping(s) have changed
                     events.add(new PortChangeEvent(prevPort,
-                                                   PortChangeType.DELETE));
+                            PortChangeType.DELETE));
                 }
 
                 // We always need to add the new port. Either no previous port
@@ -876,54 +871,55 @@
         /**
          * Compare the current ports of this switch to the newPorts list and
          * return the changes that would be applied to transfort the current
-         * ports to the new ports. No internal data structures are updated
-         * see {@link #compareAndUpdatePorts(List, boolean)}
-         *
+         * ports to the new ports. No internal data structures are updated see
+         * {@link #compareAndUpdatePorts(List, boolean)}
+         * 
          * @param newPorts the list of new ports
          * @return The list of differences between the current ports and
-         * newPortList
+         *         newPortList
          */
         public OrderedCollection<PortChangeEvent> comparePorts(
-			Collection<OFPortDesc> newPorts) {
+                Collection<OFPortDesc> newPorts) {
             return compareAndUpdatePorts(newPorts, false);
         }
 
         /**
          * Compare the current ports of this switch to the newPorts list and
          * return the changes that would be applied to transform the current
-         * ports to the new ports. No internal data structures are updated
-         * see {@link #compareAndUpdatePorts(List, boolean)}
-         *
+         * ports to the new ports. No internal data structures are updated see
+         * {@link #compareAndUpdatePorts(List, boolean)}
+         * 
          * @param newPorts the list of new ports
          * @return The list of differences between the current ports and
-         * newPortList
+         *         newPortList
          */
         public OrderedCollection<PortChangeEvent> updatePorts(
-			Collection<OFPortDesc> newPorts) {
+                Collection<OFPortDesc> newPorts) {
             return compareAndUpdatePorts(newPorts, true);
         }
 
         /**
-         * Compare the current ports stored in this switch instance with the
-         * new port list given and return the differences in the form of
+         * Compare the current ports stored in this switch instance with the new
+         * port list given and return the differences in the form of
          * PortChangeEvents. If the doUpdate flag is true, newPortList will
          * replace the current list of this switch (and update the port maps)
-         *
-         * Implementation note:
-         * Since this method can optionally modify the current ports and
-         * since it's not possible to upgrade a read-lock to a write-lock
-         * we need to hold the write-lock for the entire operation. If this
-         * becomes a problem and if compares() are common we can consider
-         * splitting in two methods but this requires lots of code duplication
-         *
+         * 
+         * Implementation note: Since this method can optionally modify the
+         * current ports and since it's not possible to upgrade a read-lock to a
+         * write-lock we need to hold the write-lock for the entire operation.
+         * If this becomes a problem and if compares() are common we can
+         * consider splitting in two methods but this requires lots of code
+         * duplication
+         * 
          * @param newPorts the list of new ports.
-         * @param doUpdate If true the newPortList will replace the current
-         * port list for this switch. If false this switch will not be changed.
+         * @param doUpdate If true the newPortList will replace the current port
+         *        list for this switch. If false this switch will not be
+         *        changed.
          * @return The list of differences between the current ports and
-         * newPorts
+         *         newPorts
          * @throws NullPointerException if newPortsList is null
          * @throws IllegalArgumentException if either port names or port numbers
-         * are duplicated in the newPortsList.
+         *         are duplicated in the newPortsList.
          */
         private OrderedCollection<PortChangeEvent> compareAndUpdatePorts(
                 Collection<OFPortDesc> newPorts, boolean doUpdate) {
@@ -935,9 +931,9 @@
                 OrderedCollection<PortChangeEvent> events =
                         new LinkedHashSetWrapper<PortChangeEvent>();
 
-                Map<Integer,OFPortDesc> newPortsByNumber =
+                Map<Integer, OFPortDesc> newPortsByNumber =
                         new HashMap<Integer, OFPortDesc>();
-                Map<String,OFPortDesc> newPortsByName =
+                Map<String, OFPortDesc> newPortsByName =
                         new HashMap<String, OFPortDesc>();
                 List<OFPortDesc> newEnabledPortList =
                         new ArrayList<OFPortDesc>();
@@ -946,7 +942,7 @@
                 List<OFPortDesc> newPortsList =
                         new ArrayList<OFPortDesc>(newPorts);
 
-                for (OFPortDesc p: newPortsList) {
+                for (OFPortDesc p : newPortsList) {
                     if (p == null) {
                         throw new NullPointerException("portList must not " +
                                 "contain null values");
@@ -956,7 +952,7 @@
                     // that every port is unique
                     OFPortDesc duplicatePort;
                     duplicatePort = newPortsByNumber.put(
-				p.getPortNo().getPortNumber(), p);
+                            p.getPortNo().getPortNumber(), p);
                     if (duplicatePort != null) {
                         String msg = String.format("Cannot have two ports " +
                                 "with the same number: %s <-> %s",
@@ -968,7 +964,7 @@
                     if (duplicatePort != null) {
                         String msg = String.format("Cannot have two ports " +
                                 "with the same name: %s <-> %s",
-                                p.toString().substring(0,80),
+                                p.toString().substring(0, 80),
                                 duplicatePort.toString().substring(0, 80));
                         throw new IllegalArgumentException(msg);
                     }
@@ -985,16 +981,16 @@
                 // to we can handle changed name<->number mappings correctly
                 // We could pull it into the loop of we address this but
                 // it's probably not worth it
-                for (OFPortDesc oldPort: this.portList) {
-                    if (!newPortsByNumber.containsKey(oldPort.getPortNo().getPortNumber())) {
+                for (OFPortDesc oldPort : this.portList) {
+                    if (!newPortsByNumber
+                            .containsKey(oldPort.getPortNo().getPortNumber())) {
                         PortChangeEvent ev =
                                 new PortChangeEvent(oldPort,
-                                                    PortChangeType.DELETE);
+                                        PortChangeType.DELETE);
                         events.add(ev);
                     }
                 }
 
-
                 if (doUpdate) {
                     portsByName = Collections.unmodifiableMap(newPortsByName);
                     portsByNumber =
@@ -1060,18 +1056,17 @@
         }
     }
 
-
-	//*******************************************
-    //    Switch stats handling
-    //*******************************************
+    // *******************************************
+    // Switch stats handling
+    // *******************************************
 
     @Override
     public Future<List<OFStatsReply>> getStatistics(OFStatsRequest<?> request)
-		throws IOException {
+            throws IOException {
         OFStatisticsFuture future = new OFStatisticsFuture(threadPool, this,
-			(int)request.getXid());
+                (int) request.getXid());
         log.info("description STAT REQUEST XID {}", request.getXid());
-        this.statsFutureMap.put((int)request.getXid(), future);
+        this.statsFutureMap.put((int) request.getXid(), future);
 
         this.channel.write(Collections.singletonList(request));
         return future;
@@ -1079,7 +1074,7 @@
 
     @Override
     public void deliverStatisticsReply(OFMessage reply) {
-        OFStatisticsFuture future = this.statsFutureMap.get((int)reply.getXid());
+        OFStatisticsFuture future = this.statsFutureMap.get((int) reply.getXid());
         if (future != null) {
             future.deliverFuture(this, reply);
             // The future will ultimately unregister itself and call
@@ -1089,7 +1084,7 @@
         // Transaction id was not found in statsFutureMap.check the other map
         IOFMessageListener caller = this.iofMsgListenersMap.get(reply.getXid());
         if (caller != null) {
-		caller.receive(this, reply, null);
+            caller.receive(this, reply, null);
         }
     }
 
@@ -1112,18 +1107,17 @@
         iofMsgListenersMap.clear();
     }
 
-
-    //*******************************************
-    //    Switch role handling
-    //*******************************************
+    // *******************************************
+    // Switch role handling
+    // *******************************************
 
     // XXX S this is completely wrong. The generation id should be obtained
     // after coordinating with all controllers connected to this switch.
     // ie. should be part of registry service (account for 1.3 vs 1.0)
     // For now we are just generating this locally and keeping it constant.
     public U64 getNextGenerationId() {
-        //TODO: Pankaj, fix nextGenerationId as part of Registry interface
-	return U64.of(generationIdSource);
+        // TODO: Pankaj, fix nextGenerationId as part of Registry interface
+        return U64.of(generationIdSource);
     }
 
     @Override
@@ -1137,10 +1131,9 @@
         this.role = role;
     }
 
-
-    //*******************************************
-    //    Switch utility methods
-    //*******************************************
+    // *******************************************
+    // Switch utility methods
+    // *******************************************
 
     private void registerOverloadCounters() throws CounterException {
         if (debugCountersRegistered) {
@@ -1154,32 +1147,32 @@
         // every level of the hierarchical counter has to be registered
         // even if they are not used
         ctrSwitch = debugCounters.registerCounter(
-                                   BASE , stringId,
-                                   "Counter for this switch",
-                                   CounterType.ALWAYS_COUNT);
+                BASE, stringId,
+                "Counter for this switch",
+                CounterType.ALWAYS_COUNT);
         ctrSwitchPktin = debugCounters.registerCounter(
-                                   BASE, stringId + "/pktin",
-                                   "Packet in counter for this switch",
-                                   CounterType.ALWAYS_COUNT);
+                BASE, stringId + "/pktin",
+                "Packet in counter for this switch",
+                CounterType.ALWAYS_COUNT);
         ctrSwitchWrite = debugCounters.registerCounter(
-                                   BASE, stringId + "/write",
-                                   "Write counter for this switch",
-                                   CounterType.ALWAYS_COUNT);
+                BASE, stringId + "/write",
+                "Write counter for this switch",
+                CounterType.ALWAYS_COUNT);
         ctrSwitchPktinDrops = debugCounters.registerCounter(
-                                   BASE, stringId + "/pktin/drops",
-                                   "Packet in throttle drop count",
-                                   CounterType.ALWAYS_COUNT,
-                                   IDebugCounterService.CTR_MDATA_WARN);
+                BASE, stringId + "/pktin/drops",
+                "Packet in throttle drop count",
+                CounterType.ALWAYS_COUNT,
+                IDebugCounterService.CTR_MDATA_WARN);
         ctrSwitchWriteDrops = debugCounters.registerCounter(
-                                   BASE, stringId + "/write/drops",
-                                   "Switch write throttle drop count",
-                                   CounterType.ALWAYS_COUNT,
-                                   IDebugCounterService.CTR_MDATA_WARN);
+                BASE, stringId + "/write/drops",
+                "Switch write throttle drop count",
+                CounterType.ALWAYS_COUNT,
+                IDebugCounterService.CTR_MDATA_WARN);
     }
 
     @Override
     public void startDriverHandshake() throws IOException {
-	log.debug("Starting driver handshake for sw {}", getStringId());
+        log.debug("Starting driver handshake for sw {}", getStringId());
         if (startDriverHandshakeCalled)
             throw new SwitchDriverSubHandshakeAlreadyStarted();
         startDriverHandshakeCalled = true;
@@ -1202,20 +1195,20 @@
 
     @Override
     @JsonIgnore
-    @LogMessageDoc(level="WARN",
-        message="Switch {switch} flow table is full",
-        explanation="The controller received flow table full " +
-                "message from the switch, could be caused by increased " +
-                "traffic pattern",
-                recommendation=LogMessageDoc.REPORT_CONTROLLER_BUG)
+    @LogMessageDoc(level = "WARN",
+            message = "Switch {switch} flow table is full",
+            explanation = "The controller received flow table full " +
+                    "message from the switch, could be caused by increased " +
+                    "traffic pattern",
+            recommendation = LogMessageDoc.REPORT_CONTROLLER_BUG)
     public void setTableFull(boolean isFull) {
         if (isFull && !flowTableFull) {
             floodlightProvider.addSwitchEvent(this.datapathId.getLong(),
                     "SWITCH_FLOW_TABLE_FULL " +
-                    "Table full error from switch", false);
+                            "Table full error from switch", false);
             log.warn("Switch {} flow table is full", stringId);
         }
-        flowTableFull  = isFull;
+        flowTableFull = isFull;
     }
 
     @Override
@@ -1231,11 +1224,11 @@
         // is sent, resulting in a wildcard-all flows
         // XXX fix this later to be sure it works for both 1.0 and 1.3
         OFMessage fm = getFactory()
-						.buildFlowDelete()
-						.setOutPort(OFPort.ANY)
-						.setOutGroup(OFGroup.ANY)
-						.setTableId(TableId.ALL)
-						.build();
+                .buildFlowDelete()
+                .setOutPort(OFPort.ANY)
+                .setOutGroup(OFGroup.ANY)
+                .setTableId(TableId.ALL)
+                .build();
 
         try {
             channel.write(Collections.singletonList(fm));
@@ -1252,7 +1245,7 @@
             try {
                 this.write(msglist);
             } catch (IOException e) {
-		log.error("Failed flushing messages", e);
+                log.error("Failed flushing messages", e);
             }
             msglist.clear();
         }
@@ -1269,7 +1262,7 @@
      * Return a read lock that must be held while calling the listeners for
      * messages from the switch. Holding the read lock prevents the active
      * switch list from being modified out from under the listeners.
-     *
+     * 
      * @return listener read lock
      */
     @JsonIgnore
@@ -1282,7 +1275,7 @@
      * list of active switches. This is to ensure that the active switch list
      * doesn't change out from under the listeners as they are handling a
      * message from the switch.
-     *
+     * 
      * @return listener write lock
      */
     @JsonIgnore