X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fprotocol_plugins%2Fopenflow%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fprotocol_plugin%2Fopenflow%2Finternal%2FDataPacketMuxDemux.java;h=2d8cdd206a7e2c651151c6515e003ba8e862c8fa;hp=cc8bcfa6b9c7c25fe828a4c7d8346dc161df4405;hb=541d0a36997f292bb037a2199463431eee538358;hpb=c8b79431119d6952b60a092e89727aa648a89bdd diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DataPacketMuxDemux.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DataPacketMuxDemux.java index cc8bcfa6b9..2d8cdd206a 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DataPacketMuxDemux.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DataPacketMuxDemux.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -44,6 +43,7 @@ import org.opendaylight.controller.sal.packet.IPluginOutDataPacketService; import org.opendaylight.controller.sal.packet.PacketResult; import org.opendaylight.controller.sal.packet.RawPacket; import org.opendaylight.controller.sal.utils.GlobalConstants; +import org.opendaylight.controller.sal.utils.HexEncode; public class DataPacketMuxDemux implements IContainerListener, IMessageListener, IDataPacketMux, IInventoryShimExternalListener { @@ -53,7 +53,8 @@ public class DataPacketMuxDemux implements IContainerListener, private ConcurrentMap swID2ISwitch = new ConcurrentHashMap(); // Gives a map between a Container and all the DataPacket listeners on SAL private ConcurrentMap pluginOutDataPacketServices = new ConcurrentHashMap(); - // Gives a map between a NodeConnector and the containers to which it belongs + // Gives a map between a NodeConnector and the containers to which it + // belongs private ConcurrentMap> nc2Container = new ConcurrentHashMap>(); // Gives a map between a Container and the FlowSpecs on it private ConcurrentMap> container2FlowSpecs = new ConcurrentHashMap>(); @@ -137,9 +138,9 @@ public class DataPacketMuxDemux implements IContainerListener, } /** - * Function called by the dependency manager when at least one - * dependency become unsatisfied or when the component is shutting - * down because for example bundle is being stopped. + * Function called by the dependency manager when at least one dependency + * become unsatisfied or when the component is shutting down because for + * example bundle is being stopped. * */ void destroy() { @@ -158,8 +159,9 @@ public class DataPacketMuxDemux implements IContainerListener, if (sw == null || msg == null || this.pluginOutDataPacketServices == null) { // Something fishy, we cannot do anything - logger.debug("sw: {} and/or msg: {} and/or pluginOutDataPacketServices: {} is null!", - new Object[]{sw, msg, this.pluginOutDataPacketServices}); + logger.debug( + "sw: {} and/or msg: {} and/or pluginOutDataPacketServices: {} is null!", + new Object[] { sw, msg, this.pluginOutDataPacketServices }); return; } if (msg instanceof OFPacketIn) { @@ -193,11 +195,18 @@ public class DataPacketMuxDemux implements IContainerListener, .get(GlobalConstants.DEFAULT.toString()); if (defaultOutService != null) { defaultOutService.receiveDataPacket(dataPacket); - logger.trace("Dispatched to apps a frame of size: {} on container: {}", - ofPacket.getPacketData().length, GlobalConstants.DEFAULT.toString()); + if (logger.isTraceEnabled()) { + logger.trace( + "Dispatched to apps a frame of size: {} on " + + "container: {}: {}", new Object[] { + ofPacket.getPacketData().length, + GlobalConstants.DEFAULT.toString(), + HexEncode.bytesToHexString(dataPacket + .getPacketData()) }); + } } // Now check the mapping between nodeConnector and - // Container and later on optinally filter based on + // Container and later on optimally filter based on // flowSpec List containersRX = this.nc2Container.get(p); if (containersRX != null) { @@ -208,9 +217,15 @@ public class DataPacketMuxDemux implements IContainerListener, if (s != null) { // TODO add filtering on a per-flowSpec base s.receiveDataPacket(dataPacket); - logger.trace("Dispatched to apps a frame of size: {} on container: {}", - ofPacket.getPacketData().length, GlobalConstants.DEFAULT.toString()); - + if (logger.isTraceEnabled()) { + logger.trace( + "Dispatched to apps a frame of size: {}" + + " on container: {}: {}", new Object[] { + ofPacket.getPacketData().length, + container, + HexEncode.bytesToHexString(dataPacket + .getPacketData()) }); + } } } } @@ -233,20 +248,20 @@ public class DataPacketMuxDemux implements IContainerListener, public void transmitDataPacket(RawPacket outPkt) { // Sanity check area if (outPkt == null) { - logger.debug("outPkt is null!"); + logger.debug("outPkt is null!"); return; } NodeConnector outPort = outPkt.getOutgoingNodeConnector(); if (outPort == null) { - logger.debug("outPort is null! outPkt: {}", outPkt); + logger.debug("outPort is null! outPkt: {}", outPkt); return; } if (!outPort.getType().equals( NodeConnector.NodeConnectorIDType.OPENFLOW)) { // The output Port is not of type OpenFlow - logger.debug("outPort is not OF Type! outPort: {}", outPort); + logger.debug("outPort is not OF Type! outPort: {}", outPort); return; } @@ -257,7 +272,7 @@ public class DataPacketMuxDemux implements IContainerListener, if (sw == null) { // If we cannot get the controller descriptor we cannot even // send out the frame - logger.debug("swID: {} - sw is null!", swID); + logger.debug("swID: {} - sw is null!", swID); return; } @@ -265,8 +280,9 @@ public class DataPacketMuxDemux implements IContainerListener, // build action OFActionOutput action = new OFActionOutput().setPort(port); // build packet out - OFPacketOut po = new OFPacketOut().setBufferId( - OFPacketOut.BUFFER_ID_NONE).setInPort(OFPort.OFPP_NONE) + OFPacketOut po = new OFPacketOut() + .setBufferId(OFPacketOut.BUFFER_ID_NONE) + .setInPort(OFPort.OFPP_NONE) .setActions(Collections.singletonList((OFAction) action)) .setActionsLength((short) OFActionOutput.MINIMUM_LENGTH); @@ -274,36 +290,37 @@ public class DataPacketMuxDemux implements IContainerListener, + data.length); po.setPacketData(data); - sw.asyncSend(po); + // send PACKET_OUT at high priority + sw.asyncFastSend(po); logger.trace("Transmitted a frame of size: {}", data.length); } public void addNode(Node node, Set props) { if (node == null) { - logger.debug("node is null!"); + logger.debug("node is null!"); return; - } + } long sid = (Long) node.getID(); ISwitch sw = controller.getSwitches().get(sid); if (sw == null) { - logger.debug("sid: {} - sw is null!", sid); - return; + logger.debug("sid: {} - sw is null!", sid); + return; } this.swID2ISwitch.put(sw.getId(), sw); } public void removeNode(Node node) { if (node == null) { - logger.debug("node is null!"); + logger.debug("node is null!"); return; } long sid = (Long) node.getID(); ISwitch sw = controller.getSwitches().get(sid); if (sw == null) { - logger.debug("sid: {} - sw is null!", sid); - return; + logger.debug("sid: {} - sw is null!", sid); + return; } this.swID2ISwitch.remove(sw.getId()); }