X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fsal%2Fimplementation%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fimplementation%2Finternal%2FDataPacketService.java;h=6f23cc735ac21b26012827176916f0beece54bb6;hb=4206a55cd7724e15e3c5b7b5b7c12f78481384cf;hp=eef43592341d69a68cc9b0f2780fef3e695856b4;hpb=e040c4e90445b4e67b4b9a281a17b974bec80a13;p=controller.git 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 eef4359234..6f23cc735a 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 @@ -1,6 +1,5 @@ - /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -40,7 +39,6 @@ import org.opendaylight.controller.sal.packet.LinkEncap; import org.opendaylight.controller.sal.packet.Packet; 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.NetUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -59,9 +57,9 @@ public class DataPacketService implements IPluginOutDataPacketService, * adding a new service, removing a service, going through all of * them maybe different. */ - private ConcurrentHashMap + private ConcurrentHashMap> pluginInDataService = - new ConcurrentHashMap(); + new ConcurrentHashMap>(); private Map statistics = new HashMap(); /** @@ -186,11 +184,11 @@ public class DataPacketService implements IPluginOutDataPacketService, String t = p.getNode() .getType(); // Now locate the TX dispatcher - IPluginInDataPacketService s = pluginInDataService - .get(t); - if (s != null) { + ProtocolService service = + pluginInDataService.get(t); + if (service != null) { try { - s.transmitDataPacket(pkt); + service.getService().transmitDataPacket(pkt); increaseStat("TXPacketSuccess"); } catch (Exception e) { increaseStat("TXPacketFailedForException"); @@ -206,66 +204,22 @@ public class DataPacketService implements IPluginOutDataPacketService, } } - void setPluginInDataService(Map props, IPluginInDataPacketService s) { - if (this.pluginInDataService == null) { - logger.error("pluginInDataService store null"); - return; - } - String type = null; - logger.trace("Received setPluginInDataService request"); - for (Object e : props.entrySet()) { - Map.Entry entry = (Map.Entry) e; - logger.trace("Prop key:({}) value:({})",entry.getKey(), entry.getValue()); - } - - Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString()); - if (value instanceof String) { - type = (String) value; - } - if (type == null) { - logger.error("Received a PluginInDataService without any " - + "protocolPluginType provided"); - } else { - this.pluginInDataService.put(type, s); - logger.debug("Stored the PluginInDataService for type: {}", type); - } + void setPluginInDataService(Map props, IPluginInDataPacketService s) { + ProtocolService.set(this.pluginInDataService, props, s, logger); } - void unsetPluginInDataService(Map props, IPluginInDataPacketService s) { - if (this.pluginInDataService == null) { - logger.error("pluginInDataService store null"); - return; - } - - String type = null; - logger.trace("Received unsetPluginInDataService request"); - for (Object e : props.entrySet()) { - Map.Entry entry = (Map.Entry) e; - logger.trace("Prop key:({}) value:({})",entry.getKey(), entry.getValue()); - } - - Object value = props.get(GlobalConstants.PROTOCOLPLUGINTYPE.toString()); - if (value instanceof String) { - type = (String) value; - } - if (type == null) { - logger.error("Received a PluginInDataService without any " - + "protocolPluginType provided"); - } else if (this.pluginInDataService.get(type).equals(s)) { - this.pluginInDataService.remove(type); - logger.debug("Removed the PluginInDataService for type: {}", type); - } + void unsetPluginInDataService(Map props, IPluginInDataPacketService s) { + ProtocolService.unset(this.pluginInDataService, props, s, logger); } - void setListenDataPacket(Map props, IListenDataPacket s) { + void setListenDataPacket(Map props, IListenDataPacket s) { if (this.listenDataPacket == null || this.indexDataPacket == null) { logger.error("data structure to store data is NULL"); return; } logger.trace("Received setListenDataPacket request"); - for (Object e : props.entrySet()) { - Map.Entry entry = (Map.Entry) e; - logger.trace("Prop key:({}) value:({})",entry.getKey(), entry.getValue()); + for (Map.Entry e : props.entrySet()) { + logger.trace("Prop key:({}) value:({})",e.getKey(), e.getValue()); } String listenerName = null; @@ -324,7 +278,6 @@ public class DataPacketService implements IPluginOutDataPacketService, // find it lets just add our dependency at the end of // the list. for (List serialListeners : this.listenDataPacket) { - int i = 0; boolean done = false; if (serialListeners.contains(lDependency)) { serialListeners.add(l); @@ -341,15 +294,14 @@ public class DataPacketService implements IPluginOutDataPacketService, } } - void unsetListenDataPacket(Map props, IListenDataPacket s) { + void unsetListenDataPacket(Map props, IListenDataPacket s) { if (this.listenDataPacket == null || this.indexDataPacket == null) { logger.error("data structure to store data is NULL"); return; } logger.trace("Received UNsetListenDataPacket request"); - for (Object e : props.entrySet()) { - Map.Entry entry = (Map.Entry) e; - logger.trace("Prop key:({}) value:({})",entry.getKey(), entry.getValue()); + for (Map.Entry e : props.entrySet()) { + logger.trace("Prop key:({}) value:({})",e.getKey(), e.getValue()); } String listenerName = null;