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 058c616ad87b281b2d7d3420fcb98cdb28f6ffa1..476b1b12f55370acaf22465f31378ad67a21bb6f 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 beec70e5ca54f9d3eda9b944a416c93e08b5727a..3cf45b11c8246fd9ab4c2d8e2feb9fc1c58507cf 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 fd043fd0ac321d4cc52ce294676b5558ee72fac4..4c2ea7313ac61be41f19b5a5409ddcdba46c27e6 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 2ab1a0583b9ac9b2dba9cb08c843438feeeac90e..00bea860de119c69fdc1298b9e0884071c2824ff 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 58f1e18730c8ee230bc24d3d38786cf2cc7693aa..8af7bc1e3144381a35eb1b78c732aac4bd8b1664 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 371dca69698f8616178e18af522a310ab12e2c1d..96b6c05934d7724a74d406d513dcb3d4bc34dca3 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 90908ef7fa96fcda1d95bec7afae8d52f89ffdb6..75c5ca9cbbbbd13cf050975a9cffcd4e916a4ad9 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 13b6e5fcfdeea3d50385106f536f9d5e1dbb3162..85d31c3c8fd39301bc0f4363553023d9f0225b7b 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 b9ce9ba5a89e34329ef3fe9089fd2272c722b5d2..f2cbb97bfa85cf491d7f8de6dd3031a571c8d47a 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 26ed4f237098ba3be7818678be684bc1af33d068..eab87a4440b356d0f734061505897e3115d87d8e 100644 (file)
@@ -127,7 +127,7 @@ public class DiscoveryService implements IInventoryShimExternalListener,
                     if (shuttingDown)
                         return;
                 } catch (Exception e2) {
-                    e2.printStackTrace();
+                    logger.error("",e2);
                 }
             }
         }
index 47ce283331c0bbe6b29fe6a231761656fdcb7728..6379b5d74e15980b18bab06d06f1e8793cbcbf0e 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 e7132597ec3ed4d4ffabaa46e2544ccceb761fe9..d00cd58c59b952b4c711ba9d215f745839e5e532 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 8d157ac29f694f721f232ba752fcac277c2fb1a5..fb295a24c068fc54dc4ca450f5b70253e87d0dab 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 a811f6529e99546300b9809e9fdb95aa667d9ddb..6fda92c02305038855e91c6280d4524edabb00a7 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 294da72bbdbe44f165b02e7bdc39e5b5d66d6b4d..9921e826fce147fc29e4440b9d07c6f068e2b294 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 64cc3fbe01045f8e2bf372fbae0ee8e360f9f908..586432d8c09a55255b1577b409302fd40b2d7456 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 2022601321f58f86cf186647cb85998cc00ab8ea..fb0a560212f304a75cbf5f16b9cebbe09bd0f4a9 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 77c55f3c10185ba9869b19903806b962655d1a60..44cb9d19d8f41969e695ba25b050ed155ac1a61c 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 b4f9cb58da7e800a115033deabb2662ee90bea40..5e4f5f81fa15ef92d044324c667f97c7ddbffccd 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 f39de8f023b792beb6c38e6845d53330d526fe8a..ed6d0e503394c820fd48da0236e55ac0f1850434 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 175a11718bff431f80e113da0da837ccadd47cc2..7d7b29c293aca87bdfcc35b48f8abda3fe4a1055 100644 (file)
@@ -188,7 +188,7 @@ public class MatchField implements Cloneable, Serializable {
                 }
             }
         } catch (CloneNotSupportedException e) {
-            e.printStackTrace();
+            logger.error("",e);
         }
         return cloned;
     }
index 1c27292117e7e0544ff80cb101fda474bb59cccf..cd9a904a608d54dcb9b5599f5e415c384698f0df 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 b1fef8f1a5ad23256f77a6eee5253f3fef89f1d5..e55873d6930e159d2ef3c922387ea9a4ff376a38 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 61d6d248c8108c9fd4b263d8cca9207ea1ffd3ef..bbe85ec66ae639c1221c39fa4b2b977a3de5ac1f 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 8628bd4813c77cb1f35f4eb2f50d6bc4def95da6..a15fecfdc6e056a606857ff05a1af350fbd074e2 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 b04ce9a07591fdd6c976fdf391c0747c26db5c89..cbf3f95b2a776dc616ebd8606697b7b46aa06f2d 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 6b068fb4adb280594660286f97ecace9773212f1..c12831dffcc61ae28632daecd43658258ae0bbaf 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 0345b90cd729001a27e0fe0da59d8eff4b42ff15..b4624323ae88a38539614dab6d16733fa3b78a83 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 954e07b16a80b31fb8345c1daffe54c6ed4ef055..6858494283a2ec6cf0ee0e56e57d88d5a3ce5960 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 78fedee36ad420fa75957268e0a9ae01219790b9..3f36beaa27b7772c441b43ac417015b62ec5f1b9 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 0cc2a1943d3bd027b8426298ff588b30a21e6d89..dd1277311e6a7bb93e9dcbf81ad62e97f25488b8 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 da725f010cffedc7646edb82f2d5087a947252ae..0ee48d5b880b8efd4039e98d0d8c217aaf095a96 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 fa0ea393ab4bcea4a3dba91395c6eac7e2d9660b..9e50059972cd96a477f926465c6dc53754a9e578 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 b1127204fb28f4e9db4a87c65abdc3e747682097..cdf867489388ba4d087d1345649e59bc112c1500 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 1c69be895afbd3e1aecda0009ee0616495960345..a0f388b8bcfe27a172468b27456d60d96c44b9b4 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 21996c0f967178f4c245b41a831725d62372c160..f701553811b6e15c191e9aac30aa5dcc61b4fd03 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 281ba52a0a6a53e38a0eb6025012537ad172ea73..0d5781bdf2354adccb4921095e5012247afc2466 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;