Logging improvements to improve efficiency - specifically in critical path. 38/338/1
authorMadhavan Kasthurirangan <mkasthur@cisco.com>
Mon, 13 May 2013 21:29:21 +0000 (14:29 -0700)
committerMadhavan Kasthurirangan <mkasthur@cisco.com>
Mon, 13 May 2013 21:29:21 +0000 (14:29 -0700)
Signed-off-by: Madhavan Kasthurirangan <mkasthur@cisco.com>
14 files changed:
opendaylight/arphandler/src/main/java/org/opendaylight/controller/arphandler/internal/ArpHandler.java
opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/Controller.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/MessageReadWriteService.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SecureMessageReadWriteService.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DataPacketMuxDemux.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/OFStatisticsManager.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/vendorextension/v6extension/V6FlowMod.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/vendorextension/v6extension/V6Match.java
opendaylight/routing/dijkstra_implementation/src/main/java/org/opendaylight/controller/routing/dijkstra_implementation/internal/DijkstraImplementation.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDP.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/Packet.java
opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/internal/SimpleForwardingImpl.java

index 3730a71f1e05db48ca74031424feaf54a26f3317..26a86c53a4694ff45ca4fbdf2ff7dbc1a2721dcb 100644 (file)
@@ -156,9 +156,11 @@ public class ArpHandler implements IHostFinder, IListenDataPacket {
          * This is to avoid continuous flooding
          */
         if (Arrays.equals(sourceMAC, getControllerMAC())) {
          * This is to avoid continuous flooding
          */
         if (Arrays.equals(sourceMAC, getControllerMAC())) {
-            logger.debug(
+            if (logger.isDebugEnabled()) {
+              logger.debug(
                     "Receive the self originated packet (srcMAC {}) --> DROP",
                     HexEncode.bytesToHexString(sourceMAC));
                     "Receive the self originated packet (srcMAC {}) --> DROP",
                     HexEncode.bytesToHexString(sourceMAC));
+            }
             return;
         }
 
             return;
         }
 
@@ -167,18 +169,16 @@ public class ArpHandler implements IHostFinder, IListenDataPacket {
             subnet = switchManager.getSubnetByNetworkAddress(sourceIP);
         }
         if (subnet == null) {
             subnet = switchManager.getSubnetByNetworkAddress(sourceIP);
         }
         if (subnet == null) {
-            logger.debug("can't find subnet matching {}, drop packet", sourceIP
-                    .toString());
+            logger.debug("can't find subnet matching {}, drop packet",sourceIP);
             return;
         }
             return;
         }
-        logger.debug("Found {} matching {}", subnet.toString(), sourceIP
-                .toString());
+        logger.debug("Found {} matching {}", subnet, sourceIP);
         /*
          * Make sure that the host is a legitimate member of this subnet
          */
         if (!subnet.hasNodeConnector(p)) {
             logger.debug("{} showing up on {} does not belong to {}",
         /*
          * Make sure that the host is a legitimate member of this subnet
          */
         if (!subnet.hasNodeConnector(p)) {
             logger.debug("{} showing up on {} does not belong to {}",
-                    new Object[] { sourceIP.toString(), p, subnet.toString() });
+                    new Object[] { sourceIP, p, subnet });
             return;
         }
 
             return;
         }
 
@@ -364,18 +364,17 @@ public class ArpHandler implements IHostFinder, IListenDataPacket {
     }
 
     public void find(InetAddress networkAddress) {
     }
 
     public void find(InetAddress networkAddress) {
-        logger.debug("Received find IP {}", networkAddress.toString());
+        logger.debug("Received find IP {}", networkAddress);
 
         Subnet subnet = null;
         if (switchManager != null) {
             subnet = switchManager.getSubnetByNetworkAddress(networkAddress);
         }
         if (subnet == null) {
 
         Subnet subnet = null;
         if (switchManager != null) {
             subnet = switchManager.getSubnetByNetworkAddress(networkAddress);
         }
         if (subnet == null) {
-            logger.debug("can't find subnet matching IP {}", networkAddress
-                    .toString());
+            logger.debug("can't find subnet matching IP {}", networkAddress);
             return;
         }
             return;
         }
-        logger.debug("found subnet {}", subnet.toString());
+        logger.debug("found subnet {}", subnet);
 
         // send a broadcast ARP Request to this interface
         sendBcastARPRequest(networkAddress, subnet);
 
         // send a broadcast ARP Request to this interface
         sendBcastARPRequest(networkAddress, subnet);
@@ -394,7 +393,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket {
         }
         if (subnet == null) {
             logger.debug("can't find subnet matching {}", host
         }
         if (subnet == null) {
             logger.debug("can't find subnet matching {}", host
-                    .getNetworkAddress().toString());
+                    .getNetworkAddress());
             return;
         }
         sendUcastARPRequest(host, subnet);
             return;
         }
         sendUcastARPRequest(host, subnet);
@@ -419,11 +418,10 @@ public class ArpHandler implements IHostFinder, IListenDataPacket {
             subnet = switchManager.getSubnetByNetworkAddress(dIP);
         }
         if (subnet == null) {
             subnet = switchManager.getSubnetByNetworkAddress(dIP);
         }
         if (subnet == null) {
-            logger.debug("can't find subnet matching {}, drop packet", dIP
-                    .toString());
+            logger.debug("can't find subnet matching {}, drop packet", dIP);
             return;
         }
             return;
         }
-        logger.debug("Found {} matching {}", subnet.toString(), dIP.toString());
+        logger.debug("Found {} matching {}", subnet, dIP);
         /*
          * unknown destination host, initiate ARP request
          */
         /*
          * unknown destination host, initiate ARP request
          */
index f416f29a25c639341f0b512d9c3b2555c49f6890..f5123eb4d0dc3393cebeb1bdae0b864a626ccc64 100644 (file)
@@ -394,8 +394,7 @@ public class HostTracker implements IfIptoHost, IfHostListener,
         arphost.setHostIP(networkAddr);
         arphost.setSent_count((short) 1);
         ARPPendingList.add(arphost);
         arphost.setHostIP(networkAddr);
         arphost.setSent_count((short) 1);
         ARPPendingList.add(arphost);
-        logger.debug("Host Added to ARPPending List, IP: {}",
-                networkAddr.toString());
+        logger.debug("Host Added to ARPPending List, IP: {}", networkAddr);
     }
 
     private void removePendingARPFromList(int index) {
     }
 
     private void removePendingARPFromList(int index) {
@@ -434,7 +433,7 @@ public class HostTracker implements IfIptoHost, IfHostListener,
                  */
                 removePendingARPFromList(i);
                 logger.debug("Host Removed from ARPPending List, IP: {}",
                  */
                 removePendingARPFromList(i);
                 logger.debug("Host Removed from ARPPending List, IP: {}",
-                        networkAddr.toString());
+                          networkAddr);
                 return;
             }
         }
                 return;
             }
         }
@@ -452,7 +451,7 @@ public class HostTracker implements IfIptoHost, IfHostListener,
                  */
                 failedARPReqList.remove(i);
                 logger.debug("Host Removed from FailedARPReqList List, IP: {}",
                  */
                 failedARPReqList.remove(i);
                 logger.debug("Host Removed from FailedARPReqList List, IP: {}",
-                        networkAddr.toString());
+                        networkAddr);
                 return;
             }
         }
                 return;
             }
         }
@@ -708,7 +707,7 @@ public class HostTracker implements IfIptoHost, IfHostListener,
             for (String switchName : hierarchy) {
                 buf.append(switchName + "/");
             }
             for (String switchName : hierarchy) {
                 buf.append(switchName + "/");
             }
-            logger.debug("{} -> {}", getContainerName(), buf.toString());
+            logger.debug("{} -> {}", getContainerName(), buf);
             num++;
         }
     }
             num++;
         }
     }
@@ -991,13 +990,15 @@ public class HostTracker implements IfIptoHost, IfHostListener,
                      * Use the services of arphandler to check if host is still
                      * there
                      */
                      * Use the services of arphandler to check if host is still
                      * there
                      */
-                    logger.trace(
-                            "ARP Probing ({}) for {}({})",
-                            new Object[] {
-                                    arp_cntdown,
-                                    host.getNetworkAddress().getHostAddress(),
-                                    HexEncode.bytesToHexString(host
-                                            .getDataLayerAddressBytes()) });
+                    if (logger.isTraceEnabled()) {
+                      logger.trace(
+                              "ARP Probing ({}) for {}({})",
+                              new Object[] {
+                                      arp_cntdown,
+                                      host.getNetworkAddress().getHostAddress(),
+                                      HexEncode.bytesToHexString(host
+                                              .getDataLayerAddressBytes()) });
+                    }
                     host.setArpSendCountDown(arp_cntdown);
                     hostFinder.probe(host);
                 }
                     host.setArpSendCountDown(arp_cntdown);
                     hostFinder.probe(host);
                 }
@@ -1160,8 +1161,10 @@ public class HostTracker implements IfIptoHost, IfHostListener,
         switch (type) {
         case REMOVED:
             long sid = (Long) node.getID();
         switch (type) {
         case REMOVED:
             long sid = (Long) node.getID();
-            logger.debug("Received removedSwitch for sw id {}",
-                    HexEncode.longToHexString(sid));
+            if (logger.isDebugEnabled()) {
+              logger.debug("Received removedSwitch for sw id {}",
+                      HexEncode.longToHexString(sid));
+            }
             for (Entry<InetAddress, HostNodeConnector> entry : hostsDB
                     .entrySet()) {
                 HostNodeConnector host = entry.getValue();
             for (Entry<InetAddress, HostNodeConnector> entry : hostsDB
                     .entrySet()) {
                 HostNodeConnector host = entry.getValue();
index bfa6f0ba0ff341fafda217a03eb32614238efc2c..2863070cc5a7a34ff0f2d95475cd5a9359a443f3 100644 (file)
@@ -70,7 +70,7 @@ public class Controller implements IController, CommandProvider {
                         ISwitch existingSwitch = switches.get(sid);
                         if (existingSwitch != null) {
                             logger.info("Replacing existing {} with New {}",
                         ISwitch existingSwitch = switches.get(sid);
                         if (existingSwitch != null) {
                             logger.info("Replacing existing {} with New {}",
-                                    existingSwitch.toString(), sw.toString());
+                                    existingSwitch, sw);
                             disconnectSwitch(existingSwitch);
                         }
                         switches.put(sid, sw);
                             disconnectSwitch(existingSwitch);
                         }
                         switches.put(sid, sw);
@@ -175,20 +175,18 @@ public class Controller implements IController, CommandProvider {
     public void addMessageListener(OFType type, IMessageListener listener) {
         IMessageListener currentListener = this.messageListeners.get(type);
         if (currentListener != null) {
     public void addMessageListener(OFType type, IMessageListener listener) {
         IMessageListener currentListener = this.messageListeners.get(type);
         if (currentListener != null) {
-            logger.warn("{} is already listened by {}", type.toString(),
-                    currentListener.toString());
+            logger.warn("{} is already listened by {}", type,
+                    currentListener);
         }
         this.messageListeners.put(type, listener);
         }
         this.messageListeners.put(type, listener);
-        logger.debug("{} is now listened by {}", type.toString(),
-                listener.toString());
+        logger.debug("{} is now listened by {}", type, listener);
     }
 
     @Override
     public void removeMessageListener(OFType type, IMessageListener listener) {
         IMessageListener currentListener = this.messageListeners.get(type);
         if ((currentListener != null) && (currentListener == listener)) {
     }
 
     @Override
     public void removeMessageListener(OFType type, IMessageListener listener) {
         IMessageListener currentListener = this.messageListeners.get(type);
         if ((currentListener != null) && (currentListener == listener)) {
-            logger.debug("{} listener {} is Removed", type.toString(),
-                    listener.toString());
+            logger.debug("{} listener {} is Removed", type, listener);
             this.messageListeners.remove(type);
         }
     }
             this.messageListeners.remove(type);
         }
     }
@@ -197,19 +195,17 @@ public class Controller implements IController, CommandProvider {
     public void addSwitchStateListener(ISwitchStateListener listener) {
         if (this.switchStateListener != null) {
             logger.warn("Switch events are already listened by {}",
     public void addSwitchStateListener(ISwitchStateListener listener) {
         if (this.switchStateListener != null) {
             logger.warn("Switch events are already listened by {}",
-                    this.switchStateListener.toString());
+                    this.switchStateListener);
         }
         this.switchStateListener = listener;
         }
         this.switchStateListener = listener;
-        logger.debug("Switch events are now listened by {}",
-                listener.toString());
+        logger.debug("Switch events are now listened by {}", listener);
     }
 
     @Override
     public void removeSwitchStateListener(ISwitchStateListener listener) {
         if ((this.switchStateListener != null)
                 && (this.switchStateListener == listener)) {
     }
 
     @Override
     public void removeSwitchStateListener(ISwitchStateListener listener) {
         if ((this.switchStateListener != null)
                 && (this.switchStateListener == listener)) {
-            logger.debug("SwitchStateListener {} is Removed",
-                    listener.toString());
+            logger.debug("SwitchStateListener {} is Removed", listener);
             this.switchStateListener = null;
         }
     }
             this.switchStateListener = null;
         }
     }
@@ -242,7 +238,7 @@ public class Controller implements IController, CommandProvider {
         if (((SwitchHandler) sw).isOperational()) {
             Long sid = sw.getId();
             if (this.switches.remove(sid, sw)) {
         if (((SwitchHandler) sw).isOperational()) {
             Long sid = sw.getId();
             if (this.switches.remove(sid, sw)) {
-                logger.warn("{} is Disconnected", sw.toString());
+                logger.warn("{} is Disconnected", sw);
                 notifySwitchDeleted(sw);
             }
         }
                 notifySwitchDeleted(sw);
             }
         }
index 3dd99e60064e181b26941985d45017ddfab97e23..d2dab0fc94483b4827890d087c996e0c9ebe3a09 100644 (file)
@@ -84,7 +84,7 @@ public class MessageReadWriteService implements IMessageReadWrite {
                 this.clientSelectionKey = this.socket.register(this.selector,
                         SelectionKey.OP_WRITE, this);
             }
                 this.clientSelectionKey = this.socket.register(this.selector,
                         SelectionKey.OP_WRITE, this);
             }
-            logger.trace("Message sent: {}", msg.toString());
+            logger.trace("Message sent: {}", msg);
         }
     }
 
         }
     }
 
index 27a5cc690625d9f780f371cab12286db976e2a3d..43a64814d8498a1842ae9f4e2ce4ee75a08aca2f 100644 (file)
@@ -190,7 +190,7 @@ public class SecureMessageReadWriteService implements IMessageReadWrite {
                         SelectionKey.OP_READ, this);
             }
 
                         SelectionKey.OP_READ, this);
             }
 
-            logger.trace("Message sent: {}", msg.toString());
+            logger.trace("Message sent: {}", msg);
         }
     }
 
         }
     }
 
index 9a05c3f4f100c46b2c357f59ae6256f4e497f491..91606f4a41daaeecd7cce64e0566c54e028ced82 100644 (file)
@@ -320,13 +320,13 @@ public class SwitchHandler implements ISwitch {
         }
 
         if (msgs == null) {
         }
 
         if (msgs == null) {
-            logger.debug("{} is down", toString());
+            logger.debug("{} is down", this);
             // the connection is down, inform core
             reportSwitchStateChange(false);
             return;
         }
         for (OFMessage msg : msgs) {
             // the connection is down, inform core
             reportSwitchStateChange(false);
             return;
         }
         for (OFMessage msg : msgs) {
-            logger.trace("Message received: {}", msg.toString());
+            logger.trace("Message received: {}", msg);
             this.lastMsgReceivedTimeStamp = System.currentTimeMillis();
             OFType type = msg.getType();
             switch (type) {
             this.lastMsgReceivedTimeStamp = System.currentTimeMillis();
             OFType type = msg.getType();
             switch (type) {
@@ -418,7 +418,7 @@ public class SwitchHandler implements ISwitch {
                             // send a probe to see if the switch is still alive
                             logger.debug(
                                     "Send idle probe (Echo Request) to {}",
                             // send a probe to see if the switch is still alive
                             logger.debug(
                                     "Send idle probe (Echo Request) to {}",
-                                    toString());
+                                    this);
                             probeSent = true;
                             OFMessage echo = factory
                                     .getMessage(OFType.ECHO_REQUEST);
                             probeSent = true;
                             OFMessage echo = factory
                                     .getMessage(OFType.ECHO_REQUEST);
@@ -462,7 +462,9 @@ public class SwitchHandler implements ISwitch {
                 || e instanceof InterruptedException
                 || e instanceof SocketException || e instanceof IOException
                 || e instanceof ClosedSelectorException) {
                 || e instanceof InterruptedException
                 || e instanceof SocketException || e instanceof IOException
                 || e instanceof ClosedSelectorException) {
-            logger.debug("Caught exception {}", e.getMessage());
+            if (logger.isDebugEnabled()) {
+              logger.debug("Caught exception {}", e.getMessage());
+            }
         } else {
             logger.warn("Caught exception ", e);
         }
         } else {
             logger.warn("Caught exception ", e);
         }
@@ -729,7 +731,7 @@ public class SwitchHandler implements ISwitch {
                     if (!transmitQ.isEmpty()) {
                         PriorityMessage pmsg = transmitQ.poll();
                         msgReadWriteService.asyncSend(pmsg.msg);
                     if (!transmitQ.isEmpty()) {
                         PriorityMessage pmsg = transmitQ.poll();
                         msgReadWriteService.asyncSend(pmsg.msg);
-                        logger.trace("Message sent: {}", pmsg.toString());
+                        logger.trace("Message sent: {}", pmsg);
                         /*
                          * If syncReply is set to true, wait for the response
                          * back.
                         /*
                          * If syncReply is set to true, wait for the response
                          * back.
@@ -883,8 +885,10 @@ public class SwitchHandler implements ISwitch {
                 // if result is not null, this means the switch can't handle
                 // this message
                 // the result if OFError already
                 // if result is not null, this means the switch can't handle
                 // this message
                 // the result if OFError already
-                logger.debug("Send {} failed --> {}", msg.getType().toString(),
-                        ((OFError) result).toString());
+                if (logger.isDebugEnabled()) {
+                  logger.debug("Send {} failed --> {}", msg.getType(),
+                               ((OFError) result));
+                }
             }
             return result;
         } catch (Exception e) {
             }
             return result;
         } catch (Exception e) {
index a8ebcb068b9399f0fee0c6b8dd6370e3b810b4d2..7614a4d128eae867ed4378f78e346da447c4d081 100644 (file)
@@ -195,13 +195,15 @@ public class DataPacketMuxDemux implements IContainerListener,
                         .get(GlobalConstants.DEFAULT.toString());
                 if (defaultOutService != null) {
                     defaultOutService.receiveDataPacket(dataPacket);
                         .get(GlobalConstants.DEFAULT.toString());
                 if (defaultOutService != null) {
                     defaultOutService.receiveDataPacket(dataPacket);
-                    logger.trace(
-                            "Dispatched to apps a frame of size: {} on container: {}: {}",
-                            new Object[] {
+                    if (logger.isTraceEnabled()) {
+                      logger.trace(
+                              "Dispatched to apps a frame of size: {} on " +
+                              "container: {}: {}", new Object[] {
                                     ofPacket.getPacketData().length,
                                     GlobalConstants.DEFAULT.toString(),
                                     HexEncode.bytesToHexString(dataPacket
                                             .getPacketData()) });
                                     ofPacket.getPacketData().length,
                                     GlobalConstants.DEFAULT.toString(),
                                     HexEncode.bytesToHexString(dataPacket
                                             .getPacketData()) });
+                    }
                 }
                 // Now check the mapping between nodeConnector and
                 // Container and later on optimally filter based on
                 }
                 // Now check the mapping between nodeConnector and
                 // Container and later on optimally filter based on
@@ -215,15 +217,15 @@ public class DataPacketMuxDemux implements IContainerListener,
                         if (s != null) {
                             // TODO add filtering on a per-flowSpec base
                             s.receiveDataPacket(dataPacket);
                         if (s != null) {
                             // TODO add filtering on a per-flowSpec base
                             s.receiveDataPacket(dataPacket);
-                            logger.trace(
-                                    "Dispatched to apps a frame of size: {} on container: {}: {}",
-                                    new Object[] {
+                            if (logger.isTraceEnabled()) {
+                              logger.trace(
+                                      "Dispatched to apps a frame of size: {}" +
+                                      " on container: {}: {}", new Object[] {
                                             ofPacket.getPacketData().length,
                                             ofPacket.getPacketData().length,
-                                            GlobalConstants.DEFAULT.toString(),
-                                            HexEncode
-                                                    .bytesToHexString(dataPacket
-                                                            .getPacketData()) });
-
+                                            container,
+                                            HexEncode.bytesToHexString(dataPacket
+                                                    .getPacketData()) });
+                            }
                         }
                     }
                 }
                         }
                     }
                 }
index 9dc8b3b6aa77f352a80ee58c5e358de0d331f46f..d6100e3fdc499c2bd53eb9eb45c414c70e8517d1 100644 (file)
@@ -176,7 +176,7 @@ public class OFStatisticsManager implements IOFStatisticsManager,
         descriptionListeners = new HashSet<IStatisticsListener>();
 
         configStatsPollIntervals();
         descriptionListeners = new HashSet<IStatisticsListener>();
 
         configStatsPollIntervals();
-        
+
         // Initialize managed timers
         statisticsTimer = new Timer();
         statisticsTimerTask = new TimerTask() {
         // Initialize managed timers
         statisticsTimer = new Timer();
         statisticsTimerTask = new TimerTask() {
@@ -703,8 +703,10 @@ public class OFStatisticsManager implements IOFStatisticsManager,
         ByteBuffer data = ByteBuffer.allocate(length);
         stat.writeTo(data);
         data.rewind();
         ByteBuffer data = ByteBuffer.allocate(length);
         stat.writeTo(data);
         data.rewind();
-        log.trace("getV6ReplyStatistics: Buffer BYTES ARE {}",
-                HexString.toHexString(data.array()));
+        if (log.isTraceEnabled()) {
+            log.trace("getV6ReplyStatistics: Buffer BYTES ARE {}",
+                    HexString.toHexString(data.array()));
+        }
 
         int vendor = data.getInt(); // first 4 bytes is vendor id.
         if (vendor != V6StatsRequest.NICIRA_VENDOR_ID) {
 
         int vendor = data.getInt(); // first 4 bytes is vendor id.
         if (vendor != V6StatsRequest.NICIRA_VENDOR_ID) {
index 888d2e63ed745adc915d8ec45880e4d08ce276f9..53f4e1d5ad0e73f61219483fc16344d34ed0ca95 100644 (file)
@@ -204,7 +204,7 @@ public class V6FlowMod extends OFVendor implements Cloneable {
                 action.writeTo(data);
             }
         }
                 action.writeTo(data);
             }
         }
-        logger.trace("{}", this.toString());
+        logger.trace("{}", this);
     }
 
     /**
     }
 
     /**
index 9921e826fce147fc29e4440b9d07c6f068e2b294..2da6b9b00891008850075e31920d02c01888ad16 100644 (file)
@@ -674,7 +674,7 @@ public class V6Match extends OFMatch implements Cloneable {
                 data.put(ipv6ext_dstport_msg);
             }
         }
                 data.put(ipv6ext_dstport_msg);
             }
         }
-        logger.trace("{}", this.toString());
+        logger.trace("{}", this);
     }
 
     private void readInPort(ByteBuffer data, int nxmLen, boolean hasMask) {
     }
 
     private void readInPort(ByteBuffer data, int nxmLen, boolean hasMask) {
index d878b231bcde7e71f4c3643970d2466d21e6629b..26ae86243b7b83279443b2a2a2b477aa85a4e179 100644 (file)
@@ -184,16 +184,14 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware {
         try {
             path = mtp.getMaxThroughputPath(src, dst);
         } catch (IllegalArgumentException ie) {
         try {
             path = mtp.getMaxThroughputPath(src, dst);
         } catch (IllegalArgumentException ie) {
-            log.debug("A vertex is yet not known between {} {}",
-                    src.toString(), dst.toString());
+            log.debug("A vertex is yet not known between {} {}", src, dst);
             return null;
         }
         Path res;
         try {
             res = new Path(path);
         } catch (ConstructionException e) {
             return null;
         }
         Path res;
         try {
             res = new Path(path);
         } catch (ConstructionException e) {
-            log.debug("A vertex is yet not known between {} {}",
-                    src.toString(), dst.toString());
+            log.debug("A vertex is yet not known between {} {}", src, dst);
             return null;
         }
         return res;
             return null;
         }
         return res;
@@ -208,16 +206,14 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware {
         try {
             path = spt.getPath(src, dst);
         } catch (IllegalArgumentException ie) {
         try {
             path = spt.getPath(src, dst);
         } catch (IllegalArgumentException ie) {
-            log.debug("A vertex is yet not known between {} {}",
-                    src.toString(), dst.toString());
+            log.debug("A vertex is yet not known between {} {}", src, dst);
             return null;
         }
         Path res;
         try {
             res = new Path(path);
         } catch (ConstructionException e) {
             return null;
         }
         Path res;
         try {
             res = new Path(path);
         } catch (ConstructionException e) {
-            log.debug("A vertex is yet not known between {} {}",
-                    src.toString(), dst.toString());
+            log.debug("A vertex is yet not known between {} {}", src, dst);
             return null;
         }
         return res;
             return null;
         }
         return res;
@@ -343,7 +339,9 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware {
         if (props != null)
             props.remove(bw);
 
         if (props != null)
             props.remove(bw);
 
-        log.debug("edgeUpdate: {} bw: {}", e.toString(), bw.getValue());
+        if (log.isDebugEnabled()) {
+          log.debug("edgeUpdate: {} bw: {}", e, bw.getValue());
+        }
 
         Short baseBW = Short.valueOf((short) 0);
         boolean add = (type == UpdateType.ADDED) ? true : false;
 
         Short baseBW = Short.valueOf((short) 0);
         boolean add = (type == UpdateType.ADDED) ? true : false;
index 5e7a214f0ea9d723c641c157b6c187b1fd59b87b..562d03b7abe503088664c28d5ecb04bb546b1258 100644 (file)
@@ -171,8 +171,10 @@ public class LLDP extends Packet {
         int lldpOffset = bitOffset; // LLDP start
         int lldpSize = size; // LLDP size
 
         int lldpOffset = bitOffset; // LLDP start
         int lldpSize = size; // LLDP size
 
-        logger.trace("LLDP: {} (offset {} bitsize {})", new Object[] {
-                HexEncode.bytesToHexString(data), lldpOffset, lldpSize });
+        if (logger.isTraceEnabled()) {
+          logger.trace("LLDP: {} (offset {} bitsize {})", new Object[] {
+                  HexEncode.bytesToHexString(data), lldpOffset, lldpSize });
+        }
         /*
          * Deserialize the TLVs until we reach the end of the packet
          */
         /*
          * Deserialize the TLVs until we reach the end of the packet
          */
@@ -212,8 +214,10 @@ public class LLDP extends Packet {
             throw new PacketException(e.getMessage());
         }
 
             throw new PacketException(e.getMessage());
         }
 
-        logger.trace("LLDP: serialized: {}",
-                HexEncode.bytesToHexString(serializedBytes));
+        if (logger.isTraceEnabled()) {
+          logger.trace("LLDP: serialized: {}",
+                  HexEncode.bytesToHexString(serializedBytes));
+        }
         return serializedBytes;
     }
 
         return serializedBytes;
     }
 
index 95f0ca8617cf8d5951ac616393abebeab51acbc0..446ec3e230e8bd11d0b9dc7451f8824b12adfda6 100644 (file)
@@ -109,10 +109,12 @@ public abstract class Packet {
              * Store the raw read value, checks the payload type and set the
              * payloadClass accordingly
              */
              * Store the raw read value, checks the payload type and set the
              * payloadClass accordingly
              */
-            logger.trace("{}: {}: {} (offset {} bitsize {})",
-                    new Object[] { this.getClass().getSimpleName(), hdrField,
-                            HexEncode.bytesToHexString(hdrFieldBytes),
-                            startOffset, numBits });
+            if (logger.isTraceEnabled()) {
+              logger.trace("{}: {}: {} (offset {} bitsize {})",
+                      new Object[] { this.getClass().getSimpleName(), hdrField,
+                              HexEncode.bytesToHexString(hdrFieldBytes),
+                              startOffset, numBits });
+            }
 
             this.setHeaderField(hdrField, hdrFieldBytes);
         }
 
             this.setHeaderField(hdrField, hdrFieldBytes);
         }
@@ -189,8 +191,10 @@ public abstract class Packet {
         }
         postSerializeCustomOperation(headerBytes);
 
         }
         postSerializeCustomOperation(headerBytes);
 
-        logger.trace("{}: {}", this.getClass().getSimpleName(),
-                HexEncode.bytesToHexString(headerBytes));
+        if (logger.isTraceEnabled()) {
+          logger.trace("{}: {}", this.getClass().getSimpleName(),
+                  HexEncode.bytesToHexString(headerBytes));
+        }
         return headerBytes;
     }
 
         return headerBytes;
     }
 
index 9e838d29e8bace591f76a3cde2168ce2e7141f5e..c2fee970ac00c8354140de8318786cd0bfcac7c4 100644 (file)
@@ -285,12 +285,13 @@ public class SimpleForwardingImpl implements IfNewHostNotify,
                         //short tag = container.getTag((Long)nextNode.getNodeID());
                         short tag = 0;
                         if (tag != 0) {
                         //short tag = container.getTag((Long)nextNode.getNodeID());
                         short tag = 0;
                         if (tag != 0) {
-                            log.debug("adding SET_VLAN " + tag
-                                    + "  for traffic leaving " + currNode + "/"
-                                    + outPort + "toward switch " + nextNode);
+                            log.debug("adding SET_VLAN {} for traffic " +
+                                    "leaving {}/{} toward switch {}",
+                                    new Object[] { tag, currNode, outPort,
+                                    nextNode});
                             actions.add(new SetVlanId(tag));
                         } else {
                             actions.add(new SetVlanId(tag));
                         } else {
-                            log.debug("No tag assigned to switch " + nextNode);
+                            log.debug("No tag assigned to switch {}", nextNode);
                         }
                     }
                 }
                         }
                     }
                 }
@@ -319,12 +320,12 @@ public class SimpleForwardingImpl implements IfNewHostNotify,
                     //short tag = container.getTag((Long)currNode.getNodeID());
                     short tag = 0;
                     if (tag != 0) {
                     //short tag = container.getTag((Long)currNode.getNodeID());
                     short tag = 0;
                     if (tag != 0) {
-                        log.debug("adding MATCH VLAN " + tag
-                                + "  for traffic entering " + currNode + "/"
-                                + inPort);
+                        log.debug("adding MATCH VLAN {} for traffic entering" +
+                                "  {}/{}",
+                                new Object[] {tag, currNode, inPort});
                         match.setField(MatchType.DL_VLAN, tag);
                     } else {
                         match.setField(MatchType.DL_VLAN, tag);
                     } else {
-                        log.debug("No tag assigned to switch " + currNode);
+                        log.debug("No tag assigned to switch {}", currNode);
                     }
                 }
             }
                     }
                 }
             }
@@ -351,10 +352,11 @@ public class SimpleForwardingImpl implements IfNewHostNotify,
             pos.put(inPort, po);
             this.rulesDB.put(key, pos);
             if (!inPort.getType().equals(NodeConnectorIDType.ALL)) {
             pos.put(inPort, po);
             this.rulesDB.put(key, pos);
             if (!inPort.getType().equals(NodeConnectorIDType.ALL)) {
-                log.debug("Adding Match(inPort=" + inPort + ",DIP="
-                        + host.getNetworkAddress().getHostAddress()
-                        + ") Action(outPort=" + outPort + ") to node "
-                        + currNode);
+                log.debug("Adding Match(inPort = {} , DIP = {})" +
+                        " Action(outPort= {}) to node {}",
+                        new Object[] { inPort,
+                        host.getNetworkAddress().getHostAddress(),
+                        outPort, currNode});
                 if ((removed_po != null)
                         && (!po.getFlow().getMatch().equals(
                                 removed_po.getFlow().getMatch()))) {
                 if ((removed_po != null)
                         && (!po.getFlow().getMatch().equals(
                                 removed_po.getFlow().getMatch()))) {
@@ -365,10 +367,10 @@ public class SimpleForwardingImpl implements IfNewHostNotify,
                 }
 
             } else {
                 }
 
             } else {
-                log.debug("Adding policy Match(DIP="
-                        + host.getNetworkAddress().getHostAddress()
-                        + ") Action(outPort=" + outPort + ") to node "
-                        + currNode);
+                log.debug("Adding policyMatch(DIP = {}) Action(outPort= {}) " + 
+                        "to node {}", new Object[] {
+                        host.getNetworkAddress().getHostAddress(), outPort,
+                        currNode});
             }
         }
     }
             }
         }
     }
@@ -419,8 +421,8 @@ public class SimpleForwardingImpl implements IfNewHostNotify,
             if ((res == null) || ((links = res.getEdges()) == null)) {
                 // Still the path that connect node to rootNode
                 // doesn't exists
             if ((res == null) || ((links = res.getEdges()) == null)) {
                 // Still the path that connect node to rootNode
                 // doesn't exists
-                log.debug("NO Route/Path between SW[" + node + "] --> SW["
-                        + rootNode + "] cleaning potentially existing entries");
+                log.debug("NO Route/Path between SW[{}] --> SW[{}] cleaning " +
+                        "potentially existing entries", node, rootNode);
                 key = new HostNodePair(host, node);
                 pos = this.rulesDB.get(key);
                 if (pos != null) {
                 key = new HostNodePair(host, node);
                 pos = this.rulesDB.get(key);
                 if (pos != null) {
@@ -436,8 +438,7 @@ public class SimpleForwardingImpl implements IfNewHostNotify,
                 continue;
             }
 
                 continue;
             }
 
-            log.debug("Route between SW[" + node + "] --> SW[" + rootNode
-                            + "]");
+            log.debug("Route between SW[{}] --> SW[{}]", node, rootNode);
             Integer curr;
             Node currNode = node;
             key = new HostNodePair(host, currNode);
             Integer curr;
             Node currNode = node;
             key = new HostNodePair(host, currNode);
@@ -528,8 +529,8 @@ public class SimpleForwardingImpl implements IfNewHostNotify,
         if ((res == null) || ((links = res.getEdges()) == null)) {
             // Still the path that connect node to rootNode
             // doesn't exists
         if ((res == null) || ((links = res.getEdges()) == null)) {
             // Still the path that connect node to rootNode
             // doesn't exists
-            log.debug("NO Route/Path between SW[" + node + "] --> SW["
-                    + rootNode + "] cleaning potentially existing entries");
+            log.debug("NO Route/Path between SW[{}] --> SW[{}] cleaning " +
+                    "potentially existing entries", node, rootNode);
             key = new HostNodePair(host, node);
             pos = this.rulesDB.get(key);
             if (pos != null) {
             key = new HostNodePair(host, node);
             pos = this.rulesDB.get(key);
             if (pos != null) {
@@ -545,7 +546,7 @@ public class SimpleForwardingImpl implements IfNewHostNotify,
             return null;
         }
 
             return null;
         }
 
-        log.debug("Route between SW[" + node + "] --> SW[" + rootNode + "]");
+        log.debug("Route between SW[{}] --> SW[{}]", node, rootNode);
         Integer curr;
         Node currNode = node;
         key = new HostNodePair(host, currNode);
         Integer curr;
         Node currNode = node;
         key = new HostNodePair(host, currNode);
@@ -557,10 +558,10 @@ public class SimpleForwardingImpl implements IfNewHostNotify,
                 continue;
             }
 
                 continue;
             }
 
-            log.debug("Link [" + currNode + "/" + link.getHeadNodeConnector()
-                    + "] --> ["
-                    + link.getHeadNodeConnector().getNode() + "/"
-                    + link.getTailNodeConnector() + "]");
+            log.debug("Link [{}/{}] --> [{}/{}]", new Object[] {
+                    currNode, link.getHeadNodeConnector(),
+                    link.getHeadNodeConnector().getNode(),
+                    link.getTailNodeConnector()});
 
             // Index all the switches to be programmed
             switchesToProgram.add(currNode);
 
             // Index all the switches to be programmed
             switchesToProgram.add(currNode);
@@ -627,8 +628,8 @@ public class SimpleForwardingImpl implements IfNewHostNotify,
                                 + po.toString() + " on switch " + swId);
                     }
                 } else {
                                 + po.toString() + " on switch " + swId);
                     }
                 } else {
-                    log.error("Cannot find a policy for SW:{" + swId
-                            + "} Host: {" + host + "}");
+                    log.error("Cannot find a policy for SW:({}) Host: ({})",
+                              swId, host);
                     /* // Now dump every single rule */
                     /* for (HostNodePair dumpkey : this.rulesDB.keySet()) { */
                     /*         po = this.rulesDB.get(dumpkey); */
                     /* // Now dump every single rule */
                     /* for (HostNodePair dumpkey : this.rulesDB.keySet()) { */
                     /*         po = this.rulesDB.get(dumpkey); */
@@ -688,7 +689,7 @@ public class SimpleForwardingImpl implements IfNewHostNotify,
         for (HostNodePair key : this.rulesDB.keySet()) {
             Node node = key.getNode();
             if (targetNode == null || node.equals(targetNode)) {
         for (HostNodePair key : this.rulesDB.keySet()) {
             Node node = key.getNode();
             if (targetNode == null || node.equals(targetNode)) {
-                log.debug("Work on " + node + " host " + key.getHost());
+                log.debug("Work on {} host {}", node, key.getHost());
                 pos = this.rulesDB.get(key);
                 for (Map.Entry<NodeConnector, FlowEntry> e : pos.entrySet()) {
                     po = e.getValue();
                 pos = this.rulesDB.get(key);
                 for (Map.Entry<NodeConnector, FlowEntry> e : pos.entrySet()) {
                     po = e.getValue();
@@ -697,7 +698,7 @@ public class SimpleForwardingImpl implements IfNewHostNotify,
                         this.frm.uninstallFlowEntry(po);
                     }
                 }
                         this.frm.uninstallFlowEntry(po);
                     }
                 }
-                log.debug("Remove " + key);
+                log.debug("Remove {}", key);
                 this.rulesDB.remove(key);
             }
         }
                 this.rulesDB.remove(key);
             }
         }
@@ -738,8 +739,8 @@ public class SimpleForwardingImpl implements IfNewHostNotify,
         }
         pl.add(po);
         log.debug("Adding Pruned Policy for SwId: {}", swId);
         }
         pl.add(po);
         log.debug("Adding Pruned Policy for SwId: {}", swId);
-        log.debug("Old Policy: " + po.toString());
-        log.debug("New Policy: " + new_po.toString());
+        log.debug("Old Policy: {}", po);
+        log.debug("New Policy: {}", new_po);
     }
 
     private void pruneExcessRules(Set<Node> switches) {
     }
 
     private void pruneExcessRules(Set<Node> switches) {
@@ -825,7 +826,7 @@ public class SimpleForwardingImpl implements IfNewHostNotify,
 
         switch (type) {
         case REMOVED:
 
         switch (type) {
         case REMOVED:
-            log.debug("Node " + node + " gone, doing a cleanup");
+            log.debug("Node {} gone, doing a cleanup", node);
             uninstallPerNodeRules(node);
             break;
         default:
             uninstallPerNodeRules(node);
             break;
         default: