Redirecting Caught and Uncaught Exceptions to OSGI Console and Log File 15/215/2
authorMaurice Qureshi <maquresh@cisco.com>
Fri, 19 Apr 2013 19:14:02 +0000 (12:14 -0700)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 22 Apr 2013 15:22:47 +0000 (15:22 +0000)
The existing mechanism int the Controller allows the exceptions to be printed only
the console. This applies to both caught and uncaught exception. If the console
buffer is not too large and gets overwritten or gets cleared, there is no way for
the user to know what exceptions occurred. This commit implements a new mechanism
by which both types of exceptions will get printed on the console as well as logged
to the file.

Signed-off-by: Maurice Qureshi <maquresh@cisco.com>
38 files changed:
opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/ClusterManager.java
opendaylight/forwarding/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/StaticRoute.java
opendaylight/forwarding/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/internal/StaticRoutingImplementation.java
opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowEntry.java
opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerImpl.java
opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/HostTracker.java
opendaylight/logging/bridge/src/main/java/org/opendaylight/controller/logging/bridge/internal/Activator.java
opendaylight/logging/bridge/src/main/java/org/opendaylight/controller/logging/bridge/internal/UncaughtExceptionHandler.java [new file with mode: 0644]
opendaylight/northbound/topology/src/test/java/org/opendaylight/controller/topology/northbound/TopologyTest.java
opendaylight/northboundtest/unit_test_suite/src/main/java/org/opendaylight/controller/northboundtest/unittestsuite/internal/API3UnitTest.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/FlowConverter.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryService.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryServiceShim.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/TopologyServiceShim.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/routing/dijkstra_implementation/src/test/java/org/opendaylight/controller/routing/dijkstra_implementation/DijkstraTest.java
opendaylight/routing/dijkstra_implementation/src/test/java/org/opendaylight/controller/routing/dijkstra_implementation/MaxThruputTest.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/Action.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/flowprogrammer/Flow.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/match/MatchField.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/BitBufferHelper.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/IPv4.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/Packet.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NetUtils.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NodeConnectorCreator.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NodeCreator.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/WriteToFile.java
opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/action/ActionTest.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
opendaylight/sal/yang-prototype/sal/sal-core-demo/src/main/java/org/opendaylight/controller/sal/demo/SALDemo.java
opendaylight/sal/yang-prototype/yang/yang-common/src/main/java/org/opendaylight/controller/yang/common/QName.java
opendaylight/samples/loadbalancer/src/main/java/org/opendaylight/controller/samples/loadbalancer/internal/LoadBalancerService.java
opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/SpanConfig.java
opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java

index 058c616..476b1b1 100644 (file)
@@ -243,10 +243,8 @@ public class ClusterManager implements IClusterServices {
             } catch (Exception e) {
                 logger.error("GossipRouter didn't start exception " + e
                         + " met");
-                StringWriter sw = new StringWriter();
                 logger.error("Stack Trace that raised the exception");
-                e.printStackTrace(new PrintWriter(sw));
-                logger.error(sw.toString());
+                logger.error("",e);
             }
         }
         logger.info("Starting the ClusterManager");
@@ -260,11 +258,9 @@ public class ClusterManager implements IClusterServices {
                 logger.debug("Started the ClusterManager");
             }
         } catch (Exception ioe) {
-            StringWriter sw = new StringWriter();
             logger.error("Cannot configure infinispan .. bailing out ");
             logger.error("Stack Trace that raised th exception");
-            ioe.printStackTrace(new PrintWriter(sw));
-            logger.error(sw.toString());
+            logger.error("",ioe);
             this.cm = null;
             this.stop();
         }
index beec70e..3cf45b1 100644 (file)
@@ -22,11 +22,16 @@ import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
 import org.opendaylight.controller.sal.utils.NodeCreator;
 
 import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * This class defines a static route object.
  */
 public class StaticRoute {
+    protected static final Logger logger = LoggerFactory
+    .getLogger(StaticRoute.class);
+
     /**
      * This Enum defines the possible types for the next hop address.
      */
@@ -249,7 +254,7 @@ public class StaticRoute {
             return InetAddress.getByAddress(BitBufferHelper
                     .toByteArray(netmask));
         } catch (Exception e) {
-            e.printStackTrace();
+            logger.error("",e);
             return null;
         }
     }
@@ -282,7 +287,7 @@ public class StaticRoute {
                 try {
                     return InetAddress.getByAddress(bbself.array());
                 } catch (Exception e) {
-                    e.printStackTrace();
+                    logger.error("",e);
                 }
             }
         }
index fd043fd..4c2ea73 100644 (file)
@@ -244,7 +244,7 @@ public class StaticRoutingImplementation implements IfNewHostNotify,
                     try {
                         ra.staticRouteUpdate(s, update);
                     } catch (Exception e) {
-                        e.printStackTrace();
+                        log.error("",e);
                     }
                 }
             }
@@ -274,7 +274,7 @@ public class StaticRoutingImplementation implements IfNewHostNotify,
                         try {
                             host = future.get();
                         } catch (Exception e) {
-                            e.printStackTrace();
+                            log.error("",e);
                         }
                     }
                 }
index 2ab1a05..00bea86 100644 (file)
@@ -18,6 +18,8 @@ import org.opendaylight.controller.sal.core.ContainerFlow;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.flowprogrammer.Flow;
 import org.opendaylight.controller.sal.match.Match;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Represents a flow applications request Forwarding Rules Manager to install
@@ -26,6 +28,8 @@ import org.opendaylight.controller.sal.match.Match;
  * For instance the flows constituting a policy all share the same group name.
  */
 public class FlowEntry implements Cloneable, Serializable {
+    protected static final Logger logger = LoggerFactory
+    .getLogger(FlowEntry.class);
     private static final long serialVersionUID = 1L;
     private String groupName; // group name
     private String flowName; // flow name (may be null)
@@ -79,7 +83,7 @@ public class FlowEntry implements Cloneable, Serializable {
             cloned = (FlowEntry) super.clone();
             cloned.flow = this.flow.clone();
         } catch (CloneNotSupportedException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         return cloned;
     }
index 58f1e18..8af7bc1 100644 (file)
@@ -2244,7 +2244,7 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager,
         try {
             node = NodeCreator.createOFNode(Long.valueOf(nodeId));
         } catch (NumberFormatException e) {
-            e.printStackTrace();
+            log.error("",e);
         }
         ci.println(this.programmer.addFlow(node, getSampleFlow(node)));
     }
@@ -2260,7 +2260,7 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager,
         try {
             node = NodeCreator.createOFNode(Long.valueOf(nodeId));
         } catch (NumberFormatException e) {
-            e.printStackTrace();
+            log.error("",e);
         }
         ci.println(this.programmer.removeFlow(node, getSampleFlow(node)));
     }
index 371dca6..96b6c05 100644 (file)
@@ -30,6 +30,7 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 
 import org.apache.felix.dm.Component;
+import org.apache.taglibs.standard.lang.jstl.DivideOperator;
 import org.opendaylight.controller.clustering.services.CacheConfigException;
 import org.opendaylight.controller.clustering.services.CacheExistException;
 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
@@ -1215,7 +1216,7 @@ public class HostTracker implements IfIptoHost, IfHostListener,
                                     nc,
                     Short.valueOf(vlan));
         } catch (UnknownHostException e) {
-            e.printStackTrace();
+            logger.error("",e);
             return new Status(StatusCode.BADREQUEST, "Invalid Address");
         }
     }
@@ -1227,7 +1228,7 @@ public class HostTracker implements IfIptoHost, IfHostListener,
             address = InetAddress.getByName(networkAddress);
             return removeStaticHostReq(address);
         } catch (UnknownHostException e) {
-            e.printStackTrace();
+            logger.error("",e);
             return new Status(StatusCode.BADREQUEST, "Invalid Address");
         }
     }
index 90908ef..75c5ca9 100644 (file)
@@ -55,6 +55,15 @@ public class Activator implements BundleActivator {
                         this.listener.logged(entry);
                     }
                 }
+                
+                /*
+                 * Install the default exception handler so that the uncaught
+                 * exceptions are handled by our customized handler. This new
+                 * handler will display the exceptions to OSGI console as well
+                 * as log to file.
+                 */
+                Thread.setDefaultUncaughtExceptionHandler(new org.opendaylight.
+                        controller.logging.bridge.internal.UncaughtExceptionHandler());
             } else {
                 this.log.error("Cannot register the LogListener because "
                         + "cannot retrive LogReaderService");
diff --git a/opendaylight/logging/bridge/src/main/java/org/opendaylight/controller/logging/bridge/internal/UncaughtExceptionHandler.java b/opendaylight/logging/bridge/src/main/java/org/opendaylight/controller/logging/bridge/internal/UncaughtExceptionHandler.java
new file mode 100644 (file)
index 0000000..6fe9c44
--- /dev/null
@@ -0,0 +1,13 @@
+package org.opendaylight.controller.logging.bridge.internal;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class UncaughtExceptionHandler implements Thread.UncaughtExceptionHandler{
+        private static Logger log = LoggerFactory.getLogger(UncaughtExceptionHandler.class);
+
+        public void uncaughtException (Thread t, Throwable e) {
+                log.error("Uncaught ExceptionHandler:", e);
+        }
+}
index 13b6e5f..85d31c3 100644 (file)
@@ -18,8 +18,12 @@ import org.opendaylight.controller.sal.core.Property;
 import org.opendaylight.controller.sal.core.State;
 import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
 import org.opendaylight.controller.sal.utils.NodeCreator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class TopologyTest {
+        protected static final Logger logger = LoggerFactory
+            .getLogger(TopologyTest.class);
 
     @Test
     public void edgePropertiesTopologyTest() {
@@ -43,13 +47,13 @@ public class TopologyTest {
         try {
             e12 = new Edge(nc12, nc21);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
             assertTrue(false);
         }
         try {
             e23 = new Edge(nc23, nc32);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
             assertTrue(false);
         }
 
index b9ce9ba..f2cbb97 100644 (file)
@@ -18,6 +18,8 @@ import org.eclipse.osgi.framework.console.CommandInterpreter;
 import org.eclipse.osgi.framework.console.CommandProvider;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.FrameworkUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * This java class provides the osgi console with the commands for running the unit test scripts for the API3
@@ -26,6 +28,9 @@ import org.osgi.framework.FrameworkUtil;
  *
  */
 public class API3UnitTest implements CommandProvider {
+    private static Logger log = LoggerFactory
+         .getLogger(API3UnitTest.class);
+
     private static final String python = "/usr/bin/python";
 
     /**
@@ -140,7 +145,7 @@ public class API3UnitTest implements CommandProvider {
             printStream(process.getErrorStream());
         } catch (Exception e) {
             System.out.println("Exception!");
-            e.printStackTrace();
+            logger.error("",e);
         }
     }
 
@@ -192,7 +197,7 @@ public class API3UnitTest implements CommandProvider {
             printStream(process.getErrorStream());
         } catch (Exception e) {
             System.out.println("Exception!");
-            e.printStackTrace();
+            logger.error("",e);
         }
     }
 
index 26ed4f2..eab87a4 100644 (file)
@@ -127,7 +127,7 @@ public class DiscoveryService implements IInventoryShimExternalListener,
                     if (shuttingDown)
                         return;
                 } catch (Exception e2) {
-                    e2.printStackTrace();
+                    logger.error("",e2);
                 }
             }
         }
index 47ce283..6379b5d 100644 (file)
@@ -67,11 +67,15 @@ import org.opendaylight.controller.sal.match.MatchField;
 import org.opendaylight.controller.sal.match.MatchType;
 import org.opendaylight.controller.sal.utils.NetUtils;
 import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Utility class for converting a SAL Flow into the OF flow and vice-versa
  */
 public class FlowConverter {
+    protected static final Logger logger = LoggerFactory
+    .getLogger(FlowConverter.class);
     private Flow flow; // SAL Flow
     private OFMatch ofMatch; // OF 1.0 match or OF 1.0 + IPv6 extension match
     private List<OFAction> actionsList; // OF 1.0 actions
@@ -680,7 +684,7 @@ public class FlowConverter {
                         try {
                             ip = InetAddress.getByAddress(addr);
                         } catch (UnknownHostException e) {
-                            e.printStackTrace();
+                            logger.error("",e);
                         }
                         salAction = new SetNwSrc(ip);
                     } else if (ofAction instanceof OFActionNetworkLayerDestination) {
@@ -691,7 +695,7 @@ public class FlowConverter {
                         try {
                             ip = InetAddress.getByAddress(addr);
                         } catch (UnknownHostException e) {
-                            e.printStackTrace();
+                            logger.error("",e);
                         }
                         salAction = new SetNwDst(ip);
                     } else if (ofAction instanceof OFActionNetworkTypeOfService) {
@@ -718,4 +722,4 @@ public class FlowConverter {
         return flow;
     }
 
-}
\ No newline at end of file
+}
index e713259..d00cd58 100644 (file)
@@ -143,7 +143,7 @@ public class InventoryService implements IInventoryShimInternalListener,
         try {
             node = new Node(NodeIDType.OPENFLOW, id);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
 
         return node;
index 8d157ac..fb295a2 100644 (file)
@@ -169,7 +169,7 @@ public class InventoryServiceShim implements IContainerListener,
                 handlePortStatusMessage(sw, (OFPortStatus) msg);
             }
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         return;
     }
index a811f65..6fda92c 100644 (file)
@@ -109,7 +109,7 @@ public class TopologyServiceShim implements IDiscoveryService,
                         return;
                     }
                 } catch (Exception e2) {
-                    e2.printStackTrace();
+                    logger.error("",e2);
                 }
             }
         }
@@ -162,7 +162,7 @@ public class TopologyServiceShim implements IDiscoveryService,
                         return;
                     }
                 } catch (Exception e2) {
-                    e2.printStackTrace();
+                    logger.error("",e2);
                 }
             }
         }
index 294da72..9921e82 100644 (file)
@@ -171,7 +171,7 @@ public class V6Match extends OFMatch implements Cloneable {
                 address = InetAddress.getByAddress(ByteBuffer.allocate(4)
                         .putInt(match.getNetworkSource()).array());
             } catch (UnknownHostException e) {
-                e.printStackTrace();
+                logger.error("",e);
             }
             this.setNetworkSource(address, null);
         } else {
@@ -186,7 +186,7 @@ public class V6Match extends OFMatch implements Cloneable {
                 address = InetAddress.getByAddress(ByteBuffer.allocate(4)
                         .putInt(match.getNetworkDestination()).array());
             } catch (UnknownHostException e) {
-                e.printStackTrace();
+                logger.error("",e);
             }
             this.setNetworkDestination(address, null);
         } else {
@@ -542,7 +542,7 @@ public class V6Match extends OFMatch implements Cloneable {
                         match_len += 20;
                     }
                 } catch (UnknownHostException e) {
-                    e.printStackTrace();
+                    logger.error("",e);
                 }
             } else if (values[0].equals(STR_NW_SRC)
                     || values[0].equals("ip_src")) {
@@ -560,7 +560,7 @@ public class V6Match extends OFMatch implements Cloneable {
                         match_len += 20;
                     }
                 } catch (UnknownHostException e) {
-                    e.printStackTrace();
+                    logger.error("",e);
                 }
             } else if (values[0].equals(STR_NW_PROTO)) {
                 this.networkProtocol = U8.t(Short.valueOf(values[1]));
index 64cc3fb..586432d 100644 (file)
@@ -269,7 +269,7 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware {
                                 .getNode(), dst
                                 .getNode(), EdgeType.DIRECTED);
                     } catch (ConstructionException e) {
-                        e.printStackTrace();
+                        log.error("",e);
                         return edgePresentInGraph;
                     }
                 }
@@ -278,7 +278,7 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware {
                 try {
                     topo.removeEdge(new Edge(src, dst));
                 } catch (ConstructionException e) {
-                    e.printStackTrace();
+                    log.error("",e);
                     return edgePresentInGraph;
                 }
 
index 2022601..fb0a560 100644 (file)
@@ -29,8 +29,12 @@ import java.util.Set;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.routing.dijkstra_implementation.internal.DijkstraImplementation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class DijkstraTest {
+    protected static final Logger logger = LoggerFactory
+    .getLogger(DijkstraTest.class);
     @Test
     public void testSinglePathRouteNoBw() {
         DijkstraImplementation imp = new DijkstraImplementation();
@@ -46,7 +50,7 @@ public class DijkstraTest {
         try {
             edge1 = new Edge(nc11, nc21);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         Set<Property> props = new HashSet<Property>();
         props.add(new Bandwidth(0));
@@ -59,7 +63,7 @@ public class DijkstraTest {
         try {
             edge2 = new Edge(nc22, nc31);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         Set<Property> props2 = new HashSet<Property>();
         props.add(new Bandwidth(0));
@@ -73,7 +77,7 @@ public class DijkstraTest {
         try {
             expectedRes = new Path(expectedPath);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         if (!res.equals(expectedRes)) {
             System.out.println("Actual Res is " + res);
@@ -97,7 +101,7 @@ public class DijkstraTest {
         try {
             edge1 = new Edge(nc11, nc21);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         Set<Property> props = new HashSet<Property>();
         props.add(new Bandwidth(0));
@@ -111,7 +115,7 @@ public class DijkstraTest {
         try {
             edge2 = new Edge(nc22, nc31);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         Set<Property> props2 = new HashSet<Property>();
         props.add(new Bandwidth(0));
@@ -125,7 +129,7 @@ public class DijkstraTest {
         try {
             edge3 = new Edge(nc12, nc32);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         Set<Property> props3 = new HashSet<Property>();
         props.add(new Bandwidth(0));
@@ -139,7 +143,7 @@ public class DijkstraTest {
         try {
             expectedRes = new Path(expectedPath);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         if (!res.equals(expectedRes)) {
             System.out.println("Actual Res is " + res);
@@ -163,7 +167,7 @@ public class DijkstraTest {
         try {
             edge1 = new Edge(nc11, nc21);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         Set<Property> props = new HashSet<Property>();
         props.add(new Bandwidth(0));
@@ -177,7 +181,7 @@ public class DijkstraTest {
         try {
             edge2 = new Edge(nc22, nc31);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         Set<Property> props2 = new HashSet<Property>();
         props.add(new Bandwidth(0));
@@ -191,7 +195,7 @@ public class DijkstraTest {
         try {
             edge3 = new Edge(nc12, nc32);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         Set<Property> props3 = new HashSet<Property>();
         props.add(new Bandwidth(0));
@@ -207,7 +211,7 @@ public class DijkstraTest {
         try {
             expectedRes = new Path(expectedPath);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         if (!res.equals(expectedRes)) {
             System.out.println("Actual Res is " + res);
index 77c55f3..44cb9d1 100644 (file)
@@ -27,9 +27,12 @@ import org.junit.Assert;
 import org.opendaylight.controller.routing.dijkstra_implementation.internal.DijkstraImplementation;
 
 import org.opendaylight.controller.sal.core.UpdateType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class MaxThruputTest {
-
+    protected static final Logger logger = LoggerFactory
+    .getLogger(MaxThruputTest.class);
     Map<Edge, Number> LinkCostMap = new HashMap<Edge, Number>();
 
     @Test
@@ -71,14 +74,14 @@ public class MaxThruputTest {
         try {
             edge1 = new Edge(nc11, nc21);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         LinkCostMap.put(edge1, 10);
         Edge edge2 = null;
         try {
             edge2 = new Edge(nc21, nc11);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         LinkCostMap.put(edge2, 10);
 
@@ -86,14 +89,14 @@ public class MaxThruputTest {
         try {
             edge3 = new Edge(nc22, nc31);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         LinkCostMap.put(edge3, 30);
         Edge edge4 = null;
         try {
             edge4 = new Edge(nc31, nc22);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         LinkCostMap.put(edge4, 30);
 
@@ -101,14 +104,14 @@ public class MaxThruputTest {
         try {
             edge5 = new Edge(nc32, nc41);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         LinkCostMap.put(edge5, 10);
         Edge edge6 = null;
         try {
             edge6 = new Edge(nc41, nc32);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         LinkCostMap.put(edge6, 10);
 
@@ -116,14 +119,14 @@ public class MaxThruputTest {
         try {
             edge7 = new Edge(nc12, nc51);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         LinkCostMap.put(edge7, 20);
         Edge edge8 = null;
         try {
             edge8 = new Edge(nc51, nc12);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         LinkCostMap.put(edge8, 20);
 
@@ -131,14 +134,14 @@ public class MaxThruputTest {
         try {
             edge9 = new Edge(nc52, nc61);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         LinkCostMap.put(edge9, 20);
         Edge edge10 = null;
         try {
             edge10 = new Edge(nc61, nc52);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         LinkCostMap.put(edge10, 20);
 
@@ -146,14 +149,14 @@ public class MaxThruputTest {
         try {
             edge11 = new Edge(nc62, nc42);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         LinkCostMap.put(edge11, 20);
         Edge edge12 = null;
         try {
             edge12 = new Edge(nc42, nc62);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         LinkCostMap.put(edge12, 20);
 
@@ -185,7 +188,7 @@ public class MaxThruputTest {
         try {
             expectedRes = new Path(expectedPath);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         if (!res.equals(expectedRes)) {
             System.out.println("Actual Res is " + res);
@@ -203,7 +206,7 @@ public class MaxThruputTest {
         try {
             expectedRes = new Path(expectedPath);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         if (!res.equals(expectedRes)) {
             System.out.println("Actual Res is " + res);
index b4f9cb5..5e4f5f8 100644 (file)
@@ -88,7 +88,7 @@ public abstract class Action {
         } catch (Exception e) {
             logger.error(e.getMessage());
             if (debug) {
-                e.printStackTrace();
+                logger.error("",e);
             }
         }
     }
index f39de8f..ed6d0e5 100644 (file)
@@ -29,6 +29,8 @@ import org.opendaylight.controller.sal.action.SetNwDst;
 import org.opendaylight.controller.sal.action.SetNwSrc;
 import org.opendaylight.controller.sal.match.Match;
 import org.opendaylight.controller.sal.utils.EtherTypes;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Represent a flow: match + actions + flow specific properties
@@ -37,6 +39,8 @@ import org.opendaylight.controller.sal.utils.EtherTypes;
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
 public class Flow implements Cloneable, Serializable {
+    protected static final Logger logger = LoggerFactory
+    .getLogger(Flow.class);
        private static final long serialVersionUID = 1L;
        @XmlElement
     private Match match;
@@ -61,7 +65,7 @@ public class Flow implements Cloneable, Serializable {
             try {
                 throw new Exception("Conflicting Match and Action list");
             } catch (Exception e) {
-                e.printStackTrace();
+                logger.error("",e);
             }
         } else {
             this.match = match;
@@ -170,7 +174,7 @@ public class Flow implements Cloneable, Serializable {
             cloned.match = this.getMatch();
             cloned.actions = this.getActions();
         } catch (CloneNotSupportedException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         return cloned;
     }
index 175a117..7d7b29c 100644 (file)
@@ -188,7 +188,7 @@ public class MatchField implements Cloneable, Serializable {
                 }
             }
         } catch (CloneNotSupportedException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         return cloned;
     }
index 1c27292..cd9a904 100644 (file)
@@ -15,6 +15,8 @@ package org.opendaylight.controller.sal.packet;
 import java.util.Arrays;
 
 import org.opendaylight.controller.sal.utils.NetUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * BitBufferHelper class that provides utility methods to
@@ -26,6 +28,8 @@ import org.opendaylight.controller.sal.utils.NetUtils;
  *
  */
 public abstract class BitBufferHelper {
+    protected static final Logger logger = LoggerFactory
+    .getLogger(BitBufferHelper.class);
 
     public static long ByteMask = 0xFF;
 
@@ -46,7 +50,7 @@ public abstract class BitBufferHelper {
                 throw new Exception(
                         "Container is too small for the number of requested bits");
             } catch (Exception e) {
-                e.printStackTrace();
+                logger.error("",e);
             }
         }
         return (data[0]);
@@ -64,7 +68,7 @@ public abstract class BitBufferHelper {
                 throw new Exception(
                         "Container is too small for the number of requested bits");
             } catch (Exception e) {
-                e.printStackTrace();
+                logger.error("",e);
             }
         }
         return (short) toNumber(data);
@@ -82,7 +86,7 @@ public abstract class BitBufferHelper {
                 throw new Exception(
                         "Container is too small for the number of requested bits");
             } catch (Exception e) {
-                e.printStackTrace();
+                logger.error("",e);
             }
         }
         return (int) toNumber(data);
@@ -100,7 +104,7 @@ public abstract class BitBufferHelper {
                 throw new Exception(
                         "Container is too small for the number of requested bits");
             } catch (Exception e) {
-                e.printStackTrace();
+                logger.error("",e);
             }
         }
         return (long) toNumber(data);
@@ -120,7 +124,7 @@ public abstract class BitBufferHelper {
                 throw new Exception(
                         "Container is too small for the number of requested bits");
             } catch (Exception e) {
-                e.printStackTrace();
+                logger.error("",e);
             }
         }
         int startOffset = data.length * NetUtils.NumBitsInAByte - numBits;
@@ -142,7 +146,7 @@ public abstract class BitBufferHelper {
                 throw new Exception(
                         "Container is too small for the number of requiested bits");
             } catch (Exception e) {
-                e.printStackTrace();
+                logger.error("",e);
             }
         }
         int startOffset = data.length * NetUtils.NumBitsInAByte - numBits;
@@ -165,7 +169,7 @@ public abstract class BitBufferHelper {
                 throw new Exception(
                         "Container is too small for the number of requested bits");
             } catch (Exception e) {
-                e.printStackTrace();
+                logger.error("",e);
             }
         }
         if (numBits > data.length * NetUtils.NumBitsInAByte) {
@@ -173,7 +177,7 @@ public abstract class BitBufferHelper {
                 throw new Exception(
                         "Trying to read more bits than contained in the data buffer");
             } catch (Exception e) {
-                e.printStackTrace();
+                logger.error("",e);
             }
         }
         int startOffset = data.length * NetUtils.NumBitsInAByte - numBits;
index b1fef8f..e55873d 100644 (file)
@@ -24,6 +24,8 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.commons.lang3.tuple.Pair;
 import org.opendaylight.controller.sal.utils.IPProtocols;
 import org.opendaylight.controller.sal.utils.NetUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Class that represents the IPv4  packet objects
@@ -32,6 +34,8 @@ import org.opendaylight.controller.sal.utils.NetUtils;
  */
 
 public class IPv4 extends Packet {
+    protected static final Logger logger = LoggerFactory
+    .getLogger(IPv4.class);
     private static final String VERSION = "Version";
     private static final String HEADERLENGTH = "HeaderLength";
     private static final String DIFFSERV = "DiffServ";
@@ -531,7 +535,7 @@ public class IPv4 extends Packet {
         try {
             payloadLength = payload.serialize().length;
         } catch (Exception e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         this.setTotalLength((short) (this.getHeaderLen() + payloadLength));
     }
index 61d6d24..bbe85ec 100644 (file)
@@ -17,6 +17,8 @@ import java.util.Map.Entry;
 import org.apache.commons.lang3.tuple.Pair;
 import org.opendaylight.controller.sal.utils.HexEncode;
 import org.opendaylight.controller.sal.utils.NetUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Abstract class which represents the generic network packet object
@@ -27,6 +29,8 @@ import org.opendaylight.controller.sal.utils.NetUtils;
  */
 
 public abstract class Packet {
+    protected static final Logger logger = LoggerFactory
+    .getLogger(Packet.class);
     // Access level granted to this packet
     protected boolean writeAccess;
     // When deserialized from wire, packet could result corrupted
@@ -260,7 +264,7 @@ public abstract class Packet {
                             .getHostAddress()
                             + " ");
                 } catch (UnknownHostException e) {
-                    e.printStackTrace();
+                    logger.error("",e);
                 }
             } else {
                 ret.append(((Long) BitBufferHelper.getLong(entry.getValue()))
index 8628bd4..a15fecf 100644 (file)
@@ -15,6 +15,9 @@ import java.net.UnknownHostException;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
  * Utility class containing the common utility functions needed
  * for operating on networking data structures
@@ -23,6 +26,8 @@ import java.util.regex.Pattern;
  *
  */
 public abstract class NetUtils {
+    protected static final Logger logger = LoggerFactory
+    .getLogger(NetUtils.class);
     /**
      * Constant holding the number of bits in a byte
      */
@@ -65,7 +70,7 @@ public abstract class NetUtils {
         try {
             ip = InetAddress.getByAddress(NetUtils.intToByteArray4(address));
         } catch (UnknownHostException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         return ip;
     }
@@ -105,7 +110,7 @@ public abstract class NetUtils {
         try {
             return InetAddress.getByAddress(address);
         } catch (UnknownHostException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         return null;
     }
@@ -276,7 +281,7 @@ public abstract class NetUtils {
         try {
             address = InetAddress.getByName(addressString);
         } catch (UnknownHostException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         return address;
     }
index b04ce9a..cbf3f95 100644 (file)
@@ -17,6 +17,8 @@ import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.core.Node.NodeIDType;
 import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * The class provides helper functions to create a node connector
@@ -24,6 +26,8 @@ import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType;
  *
  */
 public abstract class NodeConnectorCreator {
+    protected static final Logger logger = LoggerFactory
+    .getLogger(NodeConnectorCreator.class);
     /**
      * Generic NodeConnector creator
      * The nodeConnector type is inferred from the node type
@@ -38,7 +42,7 @@ public abstract class NodeConnectorCreator {
                 return new NodeConnector(NodeConnectorIDType.OPENFLOW,
                         (Short) portId, node);
             } catch (ConstructionException e1) {
-                e1.printStackTrace();
+                logger.error("",e1);
                 return null;
             }
         }
@@ -59,7 +63,7 @@ public abstract class NodeConnectorCreator {
         try {
             return new NodeConnector(nodeConnectorType, portId, node);
         } catch (ConstructionException e1) {
-            e1.printStackTrace();
+            logger.error("",e1);
             return null;
         }
     }
@@ -68,7 +72,7 @@ public abstract class NodeConnectorCreator {
         try {
             return new NodeConnector(NodeConnectorIDType.OPENFLOW, portId, node);
         } catch (ConstructionException e1) {
-            e1.printStackTrace();
+            logger.error("",e1);
             return null;
         }
     }
@@ -85,7 +89,7 @@ public abstract class NodeConnectorCreator {
             }
             return nodeConnectors;
         } catch (ConstructionException e1) {
-            e1.printStackTrace();
+            logger.error("",e1);
             return null;
         }
     }
index 6b068fb..c12831d 100644 (file)
@@ -12,6 +12,8 @@ package org.opendaylight.controller.sal.utils;
 import org.opendaylight.controller.sal.core.ConstructionException;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.Node.NodeIDType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Utility class for creating a Node object
@@ -20,11 +22,13 @@ import org.opendaylight.controller.sal.core.Node.NodeIDType;
  *
  */
 public abstract class NodeCreator {
+    protected static final Logger logger = LoggerFactory
+    .getLogger(NodeCreator.class);
     public static Node createOFNode(Long switchId) {
         try {
             return new Node(NodeIDType.OPENFLOW, switchId);
         } catch (ConstructionException e1) {
-            e1.printStackTrace();
+            logger.error("",e1);
             return null;
         }
     }
index 0345b90..b462432 100644 (file)
@@ -12,6 +12,9 @@ package org.opendaylight.controller.sal.utils;
 import java.io.*;
 import java.util.ArrayList;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
  * Convenience object to write a file
  *
@@ -19,6 +22,8 @@ import java.util.ArrayList;
  *
  */
 public class WriteToFile {
+    protected static final Logger logger = LoggerFactory
+    .getLogger(WriteToFile.class);
     private FileWriter fstream;
     private BufferedWriter bufferOut;
     private String fileName;
@@ -37,7 +42,7 @@ public class WriteToFile {
         try {
             this.bufferOut.flush();
         } catch (IOException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
     }
 
index 954e07b..6858494 100644 (file)
@@ -35,8 +35,12 @@ import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.utils.EtherTypes;
 import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class ActionTest {
+    protected static final Logger logger = LoggerFactory
+    .getLogger(ActionTest.class);
     @Test
     public void tesActionCreationValidation() {
         Action action = new PopVlan();
@@ -140,7 +144,7 @@ public class ActionTest {
         try {
             ip = InetAddress.getByName("171.71.9.52");
         } catch (UnknownHostException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
 
         action = new SetNwSrc(ip);
@@ -152,7 +156,7 @@ public class ActionTest {
         try {
             ip = InetAddress.getByName("2001:420:281:1003:f2de:f1ff:fe71:728d");
         } catch (UnknownHostException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         action = new SetNwSrc(ip);
         Assert.assertTrue(action.isValid());
@@ -222,7 +226,7 @@ public class ActionTest {
         try {
             ip = InetAddress.getByName("1.1.1.1");
         } catch (UnknownHostException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
 
         actions.add(new SetDlSrc(mac));
index 78fedee..3f36bea 100644 (file)
@@ -533,7 +533,7 @@ public class DataPacketService implements IPluginOutDataPacketService,
         try {
             data = pkt.serialize();
         } catch (Exception e) {
-            e.printStackTrace();
+            logger.error("",e);
             return null;
         }
         if (data.length <= 0) {
index 0cc2a19..dd12773 100644 (file)
@@ -248,9 +248,9 @@ public class FlowProgrammerService implements IFlowProgrammerService,
         try {
             node = new Node(NodeIDType.OPENFLOW, Long.valueOf(nodeId));
         } catch (NumberFormatException e) {
-            e.printStackTrace();
+            logger.error("",e);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         ci.println(this.addFlow(node, getSampleFlow(node)));
     }
@@ -265,9 +265,9 @@ public class FlowProgrammerService implements IFlowProgrammerService,
         try {
             node = new Node(NodeIDType.OPENFLOW, Long.valueOf(nodeId));
         } catch (NumberFormatException e) {
-            e.printStackTrace();
+            logger.error("",e);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         Flow flowA = getSampleFlow(node);
         Flow flowB = getSampleFlow(node);
@@ -288,9 +288,9 @@ public class FlowProgrammerService implements IFlowProgrammerService,
         try {
             node = new Node(NodeIDType.OPENFLOW, Long.valueOf(nodeId));
         } catch (NumberFormatException e) {
-            e.printStackTrace();
+            logger.error("",e);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         ci.println(this.removeFlow(node, getSampleFlow(node)));
     }
@@ -305,9 +305,9 @@ public class FlowProgrammerService implements IFlowProgrammerService,
         try {
             node = new Node(NodeIDType.OPENFLOW, Long.valueOf(nodeId));
         } catch (NumberFormatException e) {
-            e.printStackTrace();
+            logger.error("",e);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         ci.println(this.addFlow(node, getSampleFlowV6(node)));
     }
@@ -323,9 +323,9 @@ public class FlowProgrammerService implements IFlowProgrammerService,
         try {
             node = new Node(NodeIDType.OPENFLOW, Long.valueOf(nodeId));
         } catch (NumberFormatException e) {
-            e.printStackTrace();
+            logger.error("",e);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         ci.println(this.removeFlow(node, getSampleFlowV6(node)));
     }
index da725f0..0ee48d5 100644 (file)
@@ -328,9 +328,9 @@ public class ReadService implements IReadService, CommandProvider {
         try {
             node = new Node(NodeIDType.OPENFLOW, Long.valueOf(nodeId));
         } catch (NumberFormatException e) {
-            e.printStackTrace();
+            logger.error("",e);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         List<FlowOnNode> list = (cached) ? this.readAllFlows(node) : this
                 .nonCachedReadAllFlows(node);
@@ -355,9 +355,9 @@ public class ReadService implements IReadService, CommandProvider {
         try {
             node = new Node(NodeIDType.OPENFLOW, Long.valueOf(nodeId));
         } catch (NumberFormatException e) {
-            e.printStackTrace();
+            logger.error("",e);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         Flow flow = getSampleFlow(node);
         FlowOnNode flowOnNode = (cached) ? this.readFlow(node, flow) : this
@@ -382,9 +382,9 @@ public class ReadService implements IReadService, CommandProvider {
         try {
             node = new Node(NodeIDType.OPENFLOW, Long.valueOf(nodeId));
         } catch (NumberFormatException e) {
-            e.printStackTrace();
+            logger.error("",e);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         List<NodeConnectorStatistics> list = (cached) ? this
                 .readNodeConnectors(node) : this
@@ -438,9 +438,9 @@ public class ReadService implements IReadService, CommandProvider {
         try {
             node = new Node(NodeIDType.OPENFLOW, Long.valueOf(nodeId));
         } catch (NumberFormatException e) {
-            e.printStackTrace();
+            logger.error("",e);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         NodeDescription desc = (cached) ? this.readDescription(node) : this
                 .nonCachedReadDescription(node);
index fa0ea39..9e50059 100644 (file)
@@ -15,7 +15,12 @@ import org.opendaylight.controller.sal.core.impl.BrokerImpl;
 import org.opendaylight.controller.sal.core.impl.NotificationModule;\r
 \r
 \r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
 public class SALDemo {\r
+    protected static final Logger logger = LoggerFactory\r
+        .getLogger(SALDemo.class);\r
 \r
     static BrokerImpl broker;\r
     static DemoProviderImpl provider;\r
@@ -81,7 +86,7 @@ public class SALDemo {
             }\r
         } catch (IOException e) {\r
 \r
-            e.printStackTrace();\r
+            logger.error("",e);\r
         }\r
     }\r
 \r
index b112720..cdf8674 100644 (file)
@@ -13,6 +13,9 @@ import java.net.URISyntaxException;
 import java.text.SimpleDateFormat;\r
 import java.util.Date;\r
 \r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
 /**\r
  * The QName from XML consists of local name of element and XML namespace, but\r
  * for our use, we added module revision to it.\r
@@ -34,6 +37,8 @@ import java.util.Date;
  * \r
  */\r
 public class QName {\r
+    protected static final Logger logger = LoggerFactory\r
+        .getLogger(QName.class);\r
 \r
     private SimpleDateFormat revisionFormat = new SimpleDateFormat("yyyy-MM-dd");\r
 \r
@@ -215,7 +220,7 @@ public class QName {
                     namespace.getPort(), namespace.getPath(), query,\r
                     namespace.getFragment());\r
         } catch (URISyntaxException e) {\r
-            e.printStackTrace();\r
+            logger.error("",e);\r
         }\r
         return compositeURI;\r
     }\r
index 1c69be8..a0f388b 100644 (file)
@@ -283,7 +283,7 @@ public class LoadBalancerService implements IListenDataPacket, IConfigManager{
                             }
                         }catch (UnknownHostException e) {
                             lbsLogger.error("Pool member not found  in the network : {}",e.getMessage());
-                            e.printStackTrace();
+                            lbsLogger.error("",e);
                         }
                     }
                 }
index 21996c0..f701553 100644 (file)
@@ -23,11 +23,15 @@ import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType;
 import org.opendaylight.controller.sal.utils.GUIField;
 
 import org.opendaylight.controller.switchmanager.SpanConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * The class represents a Span Port configuration for a network node.
  */
 public class SpanConfig implements Serializable {
+    protected static final Logger logger = LoggerFactory
+    .getLogger(SpanConfig.class);
     private static final long serialVersionUID = 1L;
     private static final String guiFields[] = { GUIField.NODE.toString(),
             GUIField.SPANPORTS.toString() };
@@ -107,7 +111,7 @@ public class SpanConfig implements Serializable {
                                 NodeConnectorIDType.OPENFLOW, Short.valueOf(j),
                                 node));
                     } catch (ConstructionException e) {
-                        e.printStackTrace();
+                        logger.error("",e);
                     }
                 }
             } else {
@@ -116,9 +120,9 @@ public class SpanConfig implements Serializable {
                             NodeConnectorIDType.OPENFLOW, Short.valueOf(elem),
                             node));
                 } catch (NumberFormatException e) {
-                    e.printStackTrace();
+                    logger.error("",e);
                 } catch (ConstructionException e) {
-                    e.printStackTrace();
+                    logger.error("",e);
                 }
             }
         }
index 281ba52..0d5781b 100755 (executable)
@@ -1041,7 +1041,7 @@ public class SwitchManagerImpl implements ISwitchManager,
         try {
             nis = NetworkInterface.getNetworkInterfaces();
         } catch (SocketException e1) {
-            e1.printStackTrace();
+            log.error("",e1);
             return null;
         }
         byte[] MAC = null;
@@ -1050,7 +1050,7 @@ public class SwitchManagerImpl implements ISwitchManager,
             try {
                 MAC = ni.getHardwareAddress();
             } catch (SocketException e) {
-                e.printStackTrace();
+                log.error("",e);
             }
             if (MAC != null) {
                 return MAC;

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.