From d192c699590d441eb96a697b9e8ab7a028f18860 Mon Sep 17 00:00:00 2001 From: Maurice Qureshi Date: Fri, 19 Apr 2013 12:14:02 -0700 Subject: [PATCH] Redirecting Caught and Uncaught Exceptions to OSGI Console and Log File 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 --- .../internal/ClusterManager.java | 8 ++--- .../forwarding/staticrouting/StaticRoute.java | 9 +++-- .../internal/StaticRoutingImplementation.java | 4 +-- .../forwardingrulesmanager/FlowEntry.java | 6 +++- .../internal/ForwardingRulesManagerImpl.java | 4 +-- .../controller/hosttracker/HostTracker.java | 5 +-- .../logging/bridge/internal/Activator.java | 9 +++++ .../internal/UncaughtExceptionHandler.java | 13 ++++++++ .../topology/northbound/TopologyTest.java | 8 +++-- .../unittestsuite/internal/API3UnitTest.java | 9 +++-- .../openflow/internal/DiscoveryService.java | 2 +- .../openflow/internal/FlowConverter.java | 10 ++++-- .../openflow/internal/InventoryService.java | 2 +- .../internal/InventoryServiceShim.java | 2 +- .../internal/TopologyServiceShim.java | 4 +-- .../vendorextension/v6extension/V6Match.java | 8 ++--- .../internal/DijkstraImplementation.java | 4 +-- .../dijkstra_implementation/DijkstraTest.java | 26 ++++++++------- .../MaxThruputTest.java | 33 ++++++++++--------- .../controller/sal/action/Action.java | 2 +- .../controller/sal/flowprogrammer/Flow.java | 8 +++-- .../controller/sal/match/MatchField.java | 2 +- .../sal/packet/BitBufferHelper.java | 20 ++++++----- .../controller/sal/packet/IPv4.java | 6 +++- .../controller/sal/packet/Packet.java | 6 +++- .../controller/sal/utils/NetUtils.java | 11 +++++-- .../sal/utils/NodeConnectorCreator.java | 12 ++++--- .../controller/sal/utils/NodeCreator.java | 6 +++- .../controller/sal/utils/WriteToFile.java | 7 +++- .../controller/sal/action/ActionTest.java | 10 ++++-- .../internal/DataPacketService.java | 2 +- .../internal/FlowProgrammerService.java | 20 +++++------ .../implementation/internal/ReadService.java | 16 ++++----- .../controller/sal/demo/SALDemo.java | 7 +++- .../controller/yang/common/QName.java | 7 +++- .../internal/LoadBalancerService.java | 2 +- .../controller/switchmanager/SpanConfig.java | 10 ++++-- .../internal/SwitchManagerImpl.java | 4 +-- 38 files changed, 212 insertions(+), 112 deletions(-) create mode 100644 opendaylight/logging/bridge/src/main/java/org/opendaylight/controller/logging/bridge/internal/UncaughtExceptionHandler.java diff --git a/opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/ClusterManager.java b/opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/ClusterManager.java index 058c616ad8..476b1b12f5 100644 --- a/opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/ClusterManager.java +++ b/opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/ClusterManager.java @@ -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(); } diff --git a/opendaylight/forwarding/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/StaticRoute.java b/opendaylight/forwarding/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/StaticRoute.java index beec70e5ca..3cf45b11c8 100644 --- a/opendaylight/forwarding/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/StaticRoute.java +++ b/opendaylight/forwarding/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/StaticRoute.java @@ -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); } } } diff --git a/opendaylight/forwarding/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/internal/StaticRoutingImplementation.java b/opendaylight/forwarding/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/internal/StaticRoutingImplementation.java index fd043fd0ac..4c2ea7313a 100644 --- a/opendaylight/forwarding/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/internal/StaticRoutingImplementation.java +++ b/opendaylight/forwarding/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/internal/StaticRoutingImplementation.java @@ -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); } } } diff --git a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowEntry.java b/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowEntry.java index 2ab1a0583b..00bea860de 100644 --- a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowEntry.java +++ b/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowEntry.java @@ -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; } diff --git a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerImpl.java b/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerImpl.java index 58f1e18730..8af7bc1e31 100644 --- a/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerImpl.java +++ b/opendaylight/forwardingrulesmanager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerImpl.java @@ -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))); } diff --git a/opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/HostTracker.java b/opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/HostTracker.java index 371dca6969..96b6c05934 100644 --- a/opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/HostTracker.java +++ b/opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/HostTracker.java @@ -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"); } } diff --git a/opendaylight/logging/bridge/src/main/java/org/opendaylight/controller/logging/bridge/internal/Activator.java b/opendaylight/logging/bridge/src/main/java/org/opendaylight/controller/logging/bridge/internal/Activator.java index 90908ef7fa..75c5ca9cbb 100644 --- a/opendaylight/logging/bridge/src/main/java/org/opendaylight/controller/logging/bridge/internal/Activator.java +++ b/opendaylight/logging/bridge/src/main/java/org/opendaylight/controller/logging/bridge/internal/Activator.java @@ -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 index 0000000000..6fe9c4441f --- /dev/null +++ b/opendaylight/logging/bridge/src/main/java/org/opendaylight/controller/logging/bridge/internal/UncaughtExceptionHandler.java @@ -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); + } +} diff --git a/opendaylight/northbound/topology/src/test/java/org/opendaylight/controller/topology/northbound/TopologyTest.java b/opendaylight/northbound/topology/src/test/java/org/opendaylight/controller/topology/northbound/TopologyTest.java index 13b6e5fcfd..85d31c3c8f 100644 --- a/opendaylight/northbound/topology/src/test/java/org/opendaylight/controller/topology/northbound/TopologyTest.java +++ b/opendaylight/northbound/topology/src/test/java/org/opendaylight/controller/topology/northbound/TopologyTest.java @@ -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); } diff --git a/opendaylight/northboundtest/unit_test_suite/src/main/java/org/opendaylight/controller/northboundtest/unittestsuite/internal/API3UnitTest.java b/opendaylight/northboundtest/unit_test_suite/src/main/java/org/opendaylight/controller/northboundtest/unittestsuite/internal/API3UnitTest.java index b9ce9ba5a8..f2cbb97bfa 100644 --- a/opendaylight/northboundtest/unit_test_suite/src/main/java/org/opendaylight/controller/northboundtest/unittestsuite/internal/API3UnitTest.java +++ b/opendaylight/northboundtest/unit_test_suite/src/main/java/org/opendaylight/controller/northboundtest/unittestsuite/internal/API3UnitTest.java @@ -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); } } diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java index 26ed4f2370..eab87a4440 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java @@ -127,7 +127,7 @@ public class DiscoveryService implements IInventoryShimExternalListener, if (shuttingDown) return; } catch (Exception e2) { - e2.printStackTrace(); + logger.error("",e2); } } } diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/FlowConverter.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/FlowConverter.java index 47ce283331..6379b5d74e 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/FlowConverter.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/FlowConverter.java @@ -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 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 +} diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryService.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryService.java index e7132597ec..d00cd58c59 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryService.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryService.java @@ -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; diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryServiceShim.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryServiceShim.java index 8d157ac29f..fb295a24c0 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryServiceShim.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/InventoryServiceShim.java @@ -169,7 +169,7 @@ public class InventoryServiceShim implements IContainerListener, handlePortStatusMessage(sw, (OFPortStatus) msg); } } catch (ConstructionException e) { - e.printStackTrace(); + logger.error("",e); } return; } diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/TopologyServiceShim.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/TopologyServiceShim.java index a811f6529e..6fda92c023 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/TopologyServiceShim.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/TopologyServiceShim.java @@ -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); } } } diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/vendorextension/v6extension/V6Match.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/vendorextension/v6extension/V6Match.java index 294da72bbd..9921e826fc 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/vendorextension/v6extension/V6Match.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/vendorextension/v6extension/V6Match.java @@ -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])); diff --git a/opendaylight/routing/dijkstra_implementation/src/main/java/org/opendaylight/controller/routing/dijkstra_implementation/internal/DijkstraImplementation.java b/opendaylight/routing/dijkstra_implementation/src/main/java/org/opendaylight/controller/routing/dijkstra_implementation/internal/DijkstraImplementation.java index 64cc3fbe01..586432d8c0 100644 --- a/opendaylight/routing/dijkstra_implementation/src/main/java/org/opendaylight/controller/routing/dijkstra_implementation/internal/DijkstraImplementation.java +++ b/opendaylight/routing/dijkstra_implementation/src/main/java/org/opendaylight/controller/routing/dijkstra_implementation/internal/DijkstraImplementation.java @@ -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; } diff --git a/opendaylight/routing/dijkstra_implementation/src/test/java/org/opendaylight/controller/routing/dijkstra_implementation/DijkstraTest.java b/opendaylight/routing/dijkstra_implementation/src/test/java/org/opendaylight/controller/routing/dijkstra_implementation/DijkstraTest.java index 2022601321..fb0a560212 100644 --- a/opendaylight/routing/dijkstra_implementation/src/test/java/org/opendaylight/controller/routing/dijkstra_implementation/DijkstraTest.java +++ b/opendaylight/routing/dijkstra_implementation/src/test/java/org/opendaylight/controller/routing/dijkstra_implementation/DijkstraTest.java @@ -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 props = new HashSet(); 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 props2 = new HashSet(); 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 props = new HashSet(); 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 props2 = new HashSet(); 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 props3 = new HashSet(); 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 props = new HashSet(); 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 props2 = new HashSet(); 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 props3 = new HashSet(); 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); diff --git a/opendaylight/routing/dijkstra_implementation/src/test/java/org/opendaylight/controller/routing/dijkstra_implementation/MaxThruputTest.java b/opendaylight/routing/dijkstra_implementation/src/test/java/org/opendaylight/controller/routing/dijkstra_implementation/MaxThruputTest.java index 77c55f3c10..44cb9d19d8 100644 --- a/opendaylight/routing/dijkstra_implementation/src/test/java/org/opendaylight/controller/routing/dijkstra_implementation/MaxThruputTest.java +++ b/opendaylight/routing/dijkstra_implementation/src/test/java/org/opendaylight/controller/routing/dijkstra_implementation/MaxThruputTest.java @@ -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 LinkCostMap = new HashMap(); @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); diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/Action.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/Action.java index b4f9cb58da..5e4f5f81fa 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/Action.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/Action.java @@ -88,7 +88,7 @@ public abstract class Action { } catch (Exception e) { logger.error(e.getMessage()); if (debug) { - e.printStackTrace(); + logger.error("",e); } } } diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/flowprogrammer/Flow.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/flowprogrammer/Flow.java index f39de8f023..ed6d0e5033 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/flowprogrammer/Flow.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/flowprogrammer/Flow.java @@ -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; } diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/match/MatchField.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/match/MatchField.java index 175a11718b..7d7b29c293 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/match/MatchField.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/match/MatchField.java @@ -188,7 +188,7 @@ public class MatchField implements Cloneable, Serializable { } } } catch (CloneNotSupportedException e) { - e.printStackTrace(); + logger.error("",e); } return cloned; } diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/BitBufferHelper.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/BitBufferHelper.java index 1c27292117..cd9a904a60 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/BitBufferHelper.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/BitBufferHelper.java @@ -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; diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/IPv4.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/IPv4.java index b1fef8f1a5..e55873d693 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/IPv4.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/IPv4.java @@ -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)); } diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/Packet.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/Packet.java index 61d6d248c8..bbe85ec66a 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/Packet.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/Packet.java @@ -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())) diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NetUtils.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NetUtils.java index 8628bd4813..a15fecfdc6 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NetUtils.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NetUtils.java @@ -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; } diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NodeConnectorCreator.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NodeConnectorCreator.java index b04ce9a075..cbf3f95b2a 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NodeConnectorCreator.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NodeConnectorCreator.java @@ -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; } } diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NodeCreator.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NodeCreator.java index 6b068fb4ad..c12831dffc 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NodeCreator.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NodeCreator.java @@ -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; } } diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/WriteToFile.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/WriteToFile.java index 0345b90cd7..b4624323ae 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/WriteToFile.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/WriteToFile.java @@ -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); } } diff --git a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/action/ActionTest.java b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/action/ActionTest.java index 954e07b16a..6858494283 100644 --- a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/action/ActionTest.java +++ b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/action/ActionTest.java @@ -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)); diff --git a/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/DataPacketService.java b/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/DataPacketService.java index 78fedee36a..3f36beaa27 100644 --- a/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/DataPacketService.java +++ b/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/DataPacketService.java @@ -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) { diff --git a/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/FlowProgrammerService.java b/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/FlowProgrammerService.java index 0cc2a1943d..dd1277311e 100644 --- a/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/FlowProgrammerService.java +++ b/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/FlowProgrammerService.java @@ -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))); } diff --git a/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/ReadService.java b/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/ReadService.java index da725f010c..0ee48d5b88 100644 --- a/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/ReadService.java +++ b/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/ReadService.java @@ -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 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 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); diff --git a/opendaylight/sal/yang-prototype/sal/sal-core-demo/src/main/java/org/opendaylight/controller/sal/demo/SALDemo.java b/opendaylight/sal/yang-prototype/sal/sal-core-demo/src/main/java/org/opendaylight/controller/sal/demo/SALDemo.java index fa0ea393ab..9e50059972 100644 --- a/opendaylight/sal/yang-prototype/sal/sal-core-demo/src/main/java/org/opendaylight/controller/sal/demo/SALDemo.java +++ b/opendaylight/sal/yang-prototype/sal/sal-core-demo/src/main/java/org/opendaylight/controller/sal/demo/SALDemo.java @@ -15,7 +15,12 @@ import org.opendaylight.controller.sal.core.impl.BrokerImpl; import org.opendaylight.controller.sal.core.impl.NotificationModule; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class SALDemo { + protected static final Logger logger = LoggerFactory + .getLogger(SALDemo.class); static BrokerImpl broker; static DemoProviderImpl provider; @@ -81,7 +86,7 @@ public class SALDemo { } } catch (IOException e) { - e.printStackTrace(); + logger.error("",e); } } diff --git a/opendaylight/sal/yang-prototype/yang/yang-common/src/main/java/org/opendaylight/controller/yang/common/QName.java b/opendaylight/sal/yang-prototype/yang/yang-common/src/main/java/org/opendaylight/controller/yang/common/QName.java index b1127204fb..cdf8674893 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-common/src/main/java/org/opendaylight/controller/yang/common/QName.java +++ b/opendaylight/sal/yang-prototype/yang/yang-common/src/main/java/org/opendaylight/controller/yang/common/QName.java @@ -13,6 +13,9 @@ import java.net.URISyntaxException; import java.text.SimpleDateFormat; import java.util.Date; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * The QName from XML consists of local name of element and XML namespace, but * for our use, we added module revision to it. @@ -34,6 +37,8 @@ import java.util.Date; * */ public class QName { + protected static final Logger logger = LoggerFactory + .getLogger(QName.class); private SimpleDateFormat revisionFormat = new SimpleDateFormat("yyyy-MM-dd"); @@ -215,7 +220,7 @@ public class QName { namespace.getPort(), namespace.getPath(), query, namespace.getFragment()); } catch (URISyntaxException e) { - e.printStackTrace(); + logger.error("",e); } return compositeURI; } diff --git a/opendaylight/samples/loadbalancer/src/main/java/org/opendaylight/controller/samples/loadbalancer/internal/LoadBalancerService.java b/opendaylight/samples/loadbalancer/src/main/java/org/opendaylight/controller/samples/loadbalancer/internal/LoadBalancerService.java index 1c69be895a..a0f388b8bc 100644 --- a/opendaylight/samples/loadbalancer/src/main/java/org/opendaylight/controller/samples/loadbalancer/internal/LoadBalancerService.java +++ b/opendaylight/samples/loadbalancer/src/main/java/org/opendaylight/controller/samples/loadbalancer/internal/LoadBalancerService.java @@ -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); } } } diff --git a/opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/SpanConfig.java b/opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/SpanConfig.java index 21996c0f96..f701553811 100644 --- a/opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/SpanConfig.java +++ b/opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/SpanConfig.java @@ -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); } } } diff --git a/opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java b/opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java index 281ba52a0a..0d5781bdf2 100755 --- a/opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java +++ b/opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java @@ -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; -- 2.36.6