Logging Related Enhancements. 02/102/1
authorMadhavan Kasthurirangan <mkasthur@cisco.com>
Wed, 3 Apr 2013 21:31:31 +0000 (14:31 -0700)
committerMadhavan Kasthurirangan <mkasthur@cisco.com>
Wed, 3 Apr 2013 21:31:31 +0000 (14:31 -0700)
Signed-off-by: Madhavan Kasthurirangan <mkasthur@cisco.com>
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DataPacketMuxDemux.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/core/ComponentActivatorAbstractBase.java
opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/DataPacketService.java
opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/FlowProgrammerService.java
opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/ReadService.java

index 93e7840b01c203a741b3610e0e30f5d86236580e..cc8bcfa6b9c7c25fe828a4c7d8346dc161df4405 100644 (file)
@@ -94,7 +94,7 @@ public class DataPacketMuxDemux implements IContainerListener,
             // replication is done in the SAL implementation toward
             // the different APPS
             this.pluginOutDataPacketServices.put(containerName, s);
-            logger.debug("New outService for container:" + containerName);
+            logger.debug("New outService for container: {}", containerName);
         }
     }
 
@@ -111,7 +111,7 @@ public class DataPacketMuxDemux implements IContainerListener,
         }
         if (this.pluginOutDataPacketServices != null) {
             this.pluginOutDataPacketServices.remove(containerName);
-            logger.debug("Removed outService for container:" + containerName);
+            logger.debug("Removed outService for container: {}", containerName);
         }
     }
 
@@ -158,6 +158,8 @@ public class DataPacketMuxDemux implements IContainerListener,
         if (sw == null || msg == null
                 || this.pluginOutDataPacketServices == null) {
             // Something fishy, we cannot do anything
+               logger.debug("sw: {} and/or msg: {} and/or pluginOutDataPacketServices: {} is null!",
+                                       new Object[]{sw, msg, this.pluginOutDataPacketServices});
             return;
         }
         if (msg instanceof OFPacketIn) {
@@ -191,10 +193,8 @@ public class DataPacketMuxDemux implements IContainerListener,
                         .get(GlobalConstants.DEFAULT.toString());
                 if (defaultOutService != null) {
                     defaultOutService.receiveDataPacket(dataPacket);
-                    logger.trace("Dispatched to apps a frame of size: "
-                            + ofPacket.getPacketData().length
-                            + " on container: "
-                            + GlobalConstants.DEFAULT.toString());
+                    logger.trace("Dispatched to apps a frame of size: {} on container: {}",
+                            ofPacket.getPacketData().length, GlobalConstants.DEFAULT.toString());
                 }
                 // Now check the mapping between nodeConnector and
                 // Container and later on optinally filter based on
@@ -208,9 +208,8 @@ public class DataPacketMuxDemux implements IContainerListener,
                         if (s != null) {
                             // TODO add filtering on a per-flowSpec base
                             s.receiveDataPacket(dataPacket);
-                            logger.trace("Dispatched to apps a frame of size: "
-                                    + ofPacket.getPacketData().length
-                                    + " on container: " + container);
+                            logger.trace("Dispatched to apps a frame of size: {} on container: {}",
+                                    ofPacket.getPacketData().length, GlobalConstants.DEFAULT.toString());
 
                         }
                     }
@@ -234,17 +233,20 @@ public class DataPacketMuxDemux implements IContainerListener,
     public void transmitDataPacket(RawPacket outPkt) {
         // Sanity check area
         if (outPkt == null) {
+               logger.debug("outPkt is null!");
             return;
         }
 
         NodeConnector outPort = outPkt.getOutgoingNodeConnector();
         if (outPort == null) {
+               logger.debug("outPort is null! outPkt: {}", outPkt);
             return;
         }
 
         if (!outPort.getType().equals(
                 NodeConnector.NodeConnectorIDType.OPENFLOW)) {
             // The output Port is not of type OpenFlow
+               logger.debug("outPort is not OF Type! outPort: {}", outPort);
             return;
         }
 
@@ -255,6 +257,7 @@ public class DataPacketMuxDemux implements IContainerListener,
         if (sw == null) {
             // If we cannot get the controller descriptor we cannot even
             // send out the frame
+               logger.debug("swID: {} - sw is null!", swID);
             return;
         }
 
@@ -272,29 +275,37 @@ public class DataPacketMuxDemux implements IContainerListener,
         po.setPacketData(data);
 
         sw.asyncSend(po);
-        logger.trace("Transmitted a frame of size:" + data.length);
+        logger.trace("Transmitted a frame of size: {}", data.length);
     }
 
     public void addNode(Node node, Set<Property> props) {
-        if (node == null)
+        if (node == null) {
+               logger.debug("node is null!");
             return;
+        } 
 
         long sid = (Long) node.getID();
         ISwitch sw = controller.getSwitches().get(sid);
-        if (sw != null) {
-            this.swID2ISwitch.put(sw.getId(), sw);
+        if (sw == null) {
+               logger.debug("sid: {} - sw is null!", sid);
+               return;
         }
+        this.swID2ISwitch.put(sw.getId(), sw);
     }
 
     public void removeNode(Node node) {
-        if (node == null)
+        if (node == null) {
+               logger.debug("node is null!");
             return;
+        }
 
         long sid = (Long) node.getID();
         ISwitch sw = controller.getSwitches().get(sid);
-        if (sw != null) {
-            this.swID2ISwitch.remove(sw.getId());
+        if (sw == null) {
+               logger.debug("sid: {} - sw is null!", sid);
+               return;
         }
+        this.swID2ISwitch.remove(sw.getId());
     }
 
     @Override
@@ -315,7 +326,6 @@ public class DataPacketMuxDemux implements IContainerListener,
         if (fSpecs == null) {
             fSpecs = new CopyOnWriteArrayList<ContainerFlow>();
         }
-        boolean updateMap = false;
         switch (t) {
         case ADDED:
             if (!fSpecs.contains(previousFlow)) {
@@ -330,13 +340,6 @@ public class DataPacketMuxDemux implements IContainerListener,
         case CHANGED:
             break;
         }
-        if (updateMap) {
-            if (fSpecs.isEmpty()) {
-                this.container2FlowSpecs.remove(containerName);
-            } else {
-                this.container2FlowSpecs.put(containerName, fSpecs);
-            }
-        }
     }
 
     @Override
index 34cfd4b223625389bc6ca81841bf61f017c592cc..1fed3e1c036d53b89c2bb9ee6689128f3d937234 100644 (file)
@@ -66,7 +66,7 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware {
             this.routingAware = new HashSet<IListenRoutingUpdates>();
         }
         if (this.routingAware != null) {
-            log.debug("Adding routingAware listener: " + i);
+            log.debug("Adding routingAware listener: {}", i);
             this.routingAware.add(i);
         }
     }
@@ -140,10 +140,8 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware {
                             : avlDstThruPut;
 
                     if (avlThruPut <= 0) {
-                        log
-                                .trace(
-                                        "Edge {}: Available Throughput {} is Zero/Negative",
-                                        e, avlThruPut);
+                        log.debug("Edge {}: Available Throughput {} <= 0!",
+                                         e, avlThruPut);
                         return (double) -1;
                     }
                     return (double) (Bandwidth.BW1Pbps / avlThruPut);
@@ -177,8 +175,7 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware {
     @Override
     public synchronized Path getMaxThroughputRoute(Node src, Node dst) {
         if (mtp == null) {
-            log
-                    .error("Max Throughput Path Calculation has not been Initialized!");
+            log.error("Max Throughput Path Calculation Uninitialized!");
             return null;
         }
 
@@ -186,16 +183,16 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware {
         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.toString(),
+                          dst.toString());
             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.toString(),
+                         dst.toString());
             return null;
         }
         return res;
@@ -210,16 +207,16 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware {
         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.toString(),
+                          dst.toString());
             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.toString(),
+                          dst.toString());
             return null;
         }
         return res;
@@ -298,14 +295,14 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware {
                 if (topo.containsVertex(src.getNode())
                         && topo.inDegree(src.getNode()) == 0
                         && topo.outDegree(src.getNode()) == 0) {
-                    log.debug("Removing vertex " + src);
+                    log.debug("Removing vertex {}", src);
                     topo.removeVertex(src.getNode());
                 }
 
                 if (topo.containsVertex(dst.getNode())
                         && topo.inDegree(dst.getNode()) == 0
                         && topo.outDegree(dst.getNode()) == 0) {
-                    log.debug("Removing vertex " + dst);
+                    log.debug("Removing vertex {}", dst);
                     topo.removeVertex(dst.getNode());
                 }
             }
@@ -314,8 +311,7 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware {
                 clearMaxThroughput();
             }
         } else {
-            log.error("Cannot find topology for BW " + bw
-                    + " this is unexpected!");
+            log.error("Cannot find topology for BW {} this is unexpected!", bw);
         }
         return edgePresentInGraph;
     }
@@ -348,7 +344,7 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware {
         if (props != null)
             props.remove(bw);
 
-        log.debug("edgeUpdate: " + e.toString() + " bw: " + bw.getValue());
+        log.debug("edgeUpdate: {} bw: {}", e.toString(), bw.getValue());
 
         Short baseBW = Short.valueOf((short) 0);
         boolean add = (type == UpdateType.ADDED) ? true : false;
index d04e67b304666c88c840e7733aeeb53d5e29a1d2..88a829ba0464ab7c57e2c0d320666df78d2a7175 100644 (file)
@@ -178,7 +178,7 @@ abstract public class ComponentActivatorAbstractBase implements
     public void containerCreate(String containerName) {
         try {
             Object[] imps = getImplementations();
-            logger.trace("Creating instance " + containerName);
+            logger.trace("Creating instance {}", containerName);
             if (imps != null) {
                 for (int i = 0; i < imps.length; i++) {
                     ImmutablePair<String, Object> key = new ImmutablePair<String, Object>(
@@ -193,9 +193,8 @@ abstract public class ComponentActivatorAbstractBase implements
                         // Set the implementation so the component can manage
                         // its lifecycle
                         if (c.getService() == null) {
-                            logger
-                                    .trace("Setting implementation to:"
-                                            + imps[i]);
+                            logger.trace("Setting implementation to: {}",
+                                          imps[i]);
                             c.setImplementation(imps[i]);
                         }
 
@@ -246,7 +245,7 @@ abstract public class ComponentActivatorAbstractBase implements
     public void containerDestroy(String containerName) {
         try {
             Object[] imps = getImplementations();
-            logger.trace("Destroying instance " + containerName);
+            logger.trace("Destroying instance {}", containerName);
             if (imps != null) {
                 for (int i = 0; i < imps.length; i++) {
                     ImmutablePair<String, Object> key = new ImmutablePair<String, Object>(
@@ -330,8 +329,8 @@ abstract public class ComponentActivatorAbstractBase implements
                             // Set the implementation so the component
                             // can manage its lifesycle
                             if (c.getService() == null) {
-                                logger.trace("Setting implementation to:"
-                                        imps[i]);
+                                logger.trace("Setting implementation to: {}",
+                                        imps[i]);
                                 c.setImplementation(imps[i]);
                             }
 
@@ -397,8 +396,8 @@ abstract public class ComponentActivatorAbstractBase implements
                 try {
                     Component c = this.dbInstances.get(key);
                     if (c != null) {
-                        logger.trace("Remove component on container:"
-                                + key.getLeft() + " Object:" + key.getRight());
+                        logger.trace("Remove component on container: {} Object: {}",
+                                key.getLeft(), key.getRight());
                         this.dm.remove(c);
                     }
                 } catch (Exception nex) {
@@ -415,7 +414,7 @@ abstract public class ComponentActivatorAbstractBase implements
                 try {
                     Component c = this.dbGlobalInstances.get(key);
                     if (c != null) {
-                        logger.trace("Remove component for Object:" + key);
+                        logger.trace("Remove component for Object: {}" , key);
                         this.dm.remove(c);
                     }
                 } catch (Exception nex) {
index fe525bb081f4db9c568da0975249f1f46879de9a..78fedee36ad420fa75957268e0a9ae01219790b9 100644 (file)
@@ -236,8 +236,7 @@ public class DataPacketService implements IPluginOutDataPacketService,
         logger.trace("Received setPluginInDataService request");
         for (Object e : props.entrySet()) {
             Map.Entry entry = (Map.Entry) e;
-            logger.trace("Prop key:(" + entry.getKey() + ") value:("
-                    + entry.getValue() + ")");
+            logger.trace("Prop key:({}) value:({})",entry.getKey(), entry.getValue());
         }
 
         Object value = props.get("protocolPluginType");
@@ -249,7 +248,7 @@ public class DataPacketService implements IPluginOutDataPacketService,
                     + "protocolPluginType provided");
         } else {
             this.pluginInDataService.put(type, s);
-            logger.debug("Stored the PluginInDataService for type:" + type);
+            logger.debug("Stored the PluginInDataService for type: {}", type);
         }
     }
 
@@ -263,8 +262,7 @@ public class DataPacketService implements IPluginOutDataPacketService,
         logger.trace("Received unsetPluginInDataService request");
         for (Object e : props.entrySet()) {
             Map.Entry entry = (Map.Entry) e;
-            logger.trace("Prop key:(" + entry.getKey() + ") value:("
-                    + entry.getValue() + ")");
+            logger.trace("Prop key:({}) value:({})",entry.getKey(), entry.getValue());
         }
 
         Object value = props.get("protocoloPluginType");
@@ -276,7 +274,7 @@ public class DataPacketService implements IPluginOutDataPacketService,
                     + "protocolPluginType provided");
         } else if (this.pluginInDataService.get(type).equals(s)) {
             this.pluginInDataService.remove(type);
-            logger.debug("Removed the PluginInDataService for type:" + type);
+            logger.debug("Removed the PluginInDataService for type: {}", type);
         }
     }
 
@@ -288,8 +286,7 @@ public class DataPacketService implements IPluginOutDataPacketService,
         logger.trace("Received setListenDataPacket request");
         for (Object e : props.entrySet()) {
             Map.Entry entry = (Map.Entry) e;
-            logger.trace("Prop key:(" + entry.getKey() + ") value:("
-                    + entry.getValue() + ")");
+            logger.trace("Prop key:({}) value:({})",entry.getKey(), entry.getValue());
         }
 
         String listenerName = null;
@@ -331,7 +328,7 @@ public class DataPacketService implements IPluginOutDataPacketService,
             if (this.indexDataPacket.contains(l)) {
                 logger.error("trying to add an existing element");
             } else {
-                logger.debug("adding listener: " + listenerName);
+                logger.debug("adding listener: {}", listenerName);
                 CopyOnWriteArrayList<DataPacketListener> serialListeners = new CopyOnWriteArrayList<DataPacketListener>();
                 serialListeners.add(l);
                 this.listenDataPacket.add(serialListeners);
@@ -343,7 +340,7 @@ public class DataPacketService implements IPluginOutDataPacketService,
             if (this.indexDataPacket.contains(l)) {
                 logger.error("trying to add an existing element");
             } else {
-                logger.debug("adding listener: " + listenerName);
+                logger.debug("adding listener: {}", listenerName);
                 // Lets find the set with the dependency in it, if we
                 // find it lets just add our dependency at the end of
                 // the list.
@@ -373,8 +370,7 @@ public class DataPacketService implements IPluginOutDataPacketService,
         logger.trace("Received UNsetListenDataPacket request");
         for (Object e : props.entrySet()) {
             Map.Entry entry = (Map.Entry) e;
-            logger.trace("Prop key:(" + entry.getKey() + ") value:("
-                    + entry.getValue() + ")");
+            logger.trace("Prop key:({}) value:({})",entry.getKey(), entry.getValue());
         }
 
         String listenerName = null;
@@ -395,7 +391,7 @@ public class DataPacketService implements IPluginOutDataPacketService,
         if (!this.indexDataPacket.contains(l)) {
             logger.error("trying to remove a non-existing element");
         } else {
-            logger.debug("removing listener: " + listenerName);
+            logger.debug("removing listener: {}", listenerName);
             for (List<DataPacketListener> serialListeners : this.listenDataPacket) {
                 int i = 0;
                 boolean done = false;
index cb0a5c77a6979a0872fe63f0896c65d2a6a0d4e8..d2a49b9208fac68118ca27e70086ef9b0f59738a 100644 (file)
@@ -113,8 +113,8 @@ public class FlowProgrammerService implements IFlowProgrammerService,
         String type = null;
         for (Object e : props.entrySet()) {
             Map.Entry entry = (Map.Entry) e;
-            logger.trace("Prop key:(" + entry.getKey() + ") value:("
-                    + entry.getValue() + ")");
+            logger.trace("Prop key:({}) value:({})",entry.getKey(),
+                         entry.getValue());
         }
 
         Object value = props.get("protocolPluginType");
@@ -126,7 +126,7 @@ public class FlowProgrammerService implements IFlowProgrammerService,
                     + "protocolPluginType provided");
         } else {
             this.pluginFlowProgrammer.put(type, s);
-            logger.debug("Stored the pluginFlowProgrammer for type:" + type);
+            logger.debug("Stored the pluginFlowProgrammer for type: {}",type);
         }
     }
 
@@ -141,8 +141,8 @@ public class FlowProgrammerService implements IFlowProgrammerService,
         logger.debug("Received unsetpluginFlowProgrammer request");
         for (Object e : props.entrySet()) {
             Map.Entry entry = (Map.Entry) e;
-            logger.trace("Prop key:(" + entry.getKey() + ") value:("
-                    + entry.getValue() + ")");
+            logger.trace("Prop key:({}) value:({})",entry.getKey(),
+                       entry.getValue());
         }
 
         Object value = props.get("protocoloPluginType");
@@ -154,7 +154,7 @@ public class FlowProgrammerService implements IFlowProgrammerService,
                     + "protocolPluginType provided");
         } else if (this.pluginFlowProgrammer.get(type).equals(s)) {
             this.pluginFlowProgrammer.remove(type);
-            logger.debug("Removed the pluginFlowProgrammer for type:" + type);
+            logger.debug("Removed the pluginFlowProgrammer for type: {}", type);
         }
     }
 
index 81bfa5b63fb48b7a8fa18b05ea5b2a4340cad344..da725f010cffedc7646edb82f2d5087a947252ae 100644 (file)
@@ -109,8 +109,8 @@ public class ReadService implements IReadService, CommandProvider {
         String type = null;
         for (Object e : props.entrySet()) {
             Map.Entry entry = (Map.Entry) e;
-            logger.trace("Prop key:(" + entry.getKey() + ") value:("
-                    + entry.getValue() + ")");
+            logger.trace("Prop key:({}) value:({})", entry.getKey(),
+                       entry.getValue());
         }
 
         Object value = props.get("protocolPluginType");
@@ -122,7 +122,7 @@ public class ReadService implements IReadService, CommandProvider {
                     + "protocolPluginType provided");
         } else {
             this.pluginReader.put(type, s);
-            logger.debug("Stored the pluginReader for type:" + type);
+            logger.debug("Stored the pluginReader for type: {}", type);
         }
     }
 
@@ -136,8 +136,8 @@ public class ReadService implements IReadService, CommandProvider {
         logger.debug("Received unsetpluginReader request");
         for (Object e : props.entrySet()) {
             Map.Entry entry = (Map.Entry) e;
-            logger.trace("Prop key:(" + entry.getKey() + ") value:("
-                    + entry.getValue() + ")");
+            logger.trace("Prop key:({}) value:({})", entry.getKey(),
+                       entry.getValue());
         }
 
         Object value = props.get("protocoloPluginType");
@@ -149,7 +149,7 @@ public class ReadService implements IReadService, CommandProvider {
                     + "protocolPluginType provided");
         } else if (this.pluginReader.get(type).equals(s)) {
             this.pluginReader.remove(type);
-            logger.debug("Removed the pluginReader for type:" + type);
+            logger.debug("Removed the pluginReader for type: {}", type);
         }
     }
 
@@ -161,7 +161,7 @@ public class ReadService implements IReadService, CommandProvider {
                     .readFlow(node, flow, true);
             }
         }
-        logger.warn("Plugin unuvailable");
+        logger.warn("Plugin unavailable");
         return null;
     }
 
@@ -173,7 +173,7 @@ public class ReadService implements IReadService, CommandProvider {
                     .readFlow(node, flow, false);
             }
         }
-        logger.warn("Plugin unuvailable");
+        logger.warn("Plugin unavailable");
         return null;
     }
 
@@ -185,7 +185,7 @@ public class ReadService implements IReadService, CommandProvider {
                     .readAllFlow(node, true);
             }
         }
-        logger.warn("Plugin unuvailable");
+        logger.warn("Plugin unavailable");
         return null;
     }
 
@@ -197,7 +197,7 @@ public class ReadService implements IReadService, CommandProvider {
                     .readAllFlow(node, false);
             }
         }
-        logger.warn("Plugin unuvailable");
+        logger.warn("Plugin unavailable");
         return null;
     }
 
@@ -209,7 +209,7 @@ public class ReadService implements IReadService, CommandProvider {
                     .readDescription(node, true);
             }
         }
-        logger.warn("Plugin unuvailable");
+        logger.warn("Plugin unavailable");
         return null;
     }
 
@@ -221,7 +221,7 @@ public class ReadService implements IReadService, CommandProvider {
                     .readDescription(node, false);
             }
         }
-        logger.warn("Plugin unuvailable");
+        logger.warn("Plugin unavailable");
         return null;
     }
 
@@ -234,7 +234,7 @@ public class ReadService implements IReadService, CommandProvider {
                     .readNodeConnector(connector, true);
             }
         }
-        logger.warn("Plugin unuvailable");
+        logger.warn("Plugin unavailable");
         return null;
     }
 
@@ -248,7 +248,7 @@ public class ReadService implements IReadService, CommandProvider {
                     .readNodeConnector(connector, false);
             }
         }
-        logger.warn("Plugin unuvailable");
+        logger.warn("Plugin unavailable");
         return null;
     }
 
@@ -260,7 +260,7 @@ public class ReadService implements IReadService, CommandProvider {
                     .readAllNodeConnector(node, true);
             }
         }
-        logger.warn("Plugin unuvailable");
+        logger.warn("Plugin unavailable");
         return null;
     }
 
@@ -272,7 +272,7 @@ public class ReadService implements IReadService, CommandProvider {
                     .readAllNodeConnector(node, false);
             }
         }
-        logger.warn("Plugin unuvailable");
+        logger.warn("Plugin unavailable");
         return null;
     }
 
@@ -285,7 +285,7 @@ public class ReadService implements IReadService, CommandProvider {
                     .getTransmitRate(connector);
             }
         }
-        logger.warn("Plugin unuvailable");
+        logger.warn("Plugin unavailable");
         return 0;
     }