Merge "Logging Bridge need to show the source of the OSGi Log events"
authorAlessandro Boch <aboch@cisco.com>
Thu, 8 Aug 2013 18:05:38 +0000 (18:05 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 8 Aug 2013 18:05:38 +0000 (18:05 +0000)
12 files changed:
opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManager.java
opendaylight/northbound/subnets/src/main/java/org/opendaylight/controller/subnets/northbound/SubnetsNorthboundJAXRS.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/OFStatisticsManager.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/ReadService.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/ReadServiceFilter.java
opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/ReadService.java
opendaylight/statisticsmanager/implementation/src/main/java/org/opendaylight/controller/statisticsmanager/internal/StatisticsManager.java
opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Subnet.java
opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SubnetConfig.java
opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManager.java
opendaylight/switchmanager/implementation/src/test/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerTest.java
opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/Devices.java

index cade2666883c66b4f8ca3e838b9b60524903ce88..836c12749f0b94c6cce567910f60b5f0af797d81 100644 (file)
@@ -131,7 +131,8 @@ public class ForwardingRulesManager implements IForwardingRulesManager, PortGrou
     private ConcurrentMap<FlowEntry, FlowEntry> inactiveFlows;
 
     private IContainer container;
-    private Set<IForwardingRulesManagerAware> frmAware;
+    private Set<IForwardingRulesManagerAware> frmAware =
+        Collections.synchronizedSet(new HashSet<IForwardingRulesManagerAware>());
     private PortGroupProvider portGroupProvider;
     private IFlowProgrammerService programmer;
     private IClusterContainerServices clusterContainerService = null;
@@ -2138,7 +2139,6 @@ public class ForwardingRulesManager implements IForwardingRulesManager, PortGrou
      *
      */
     void init() {
-        frmAware = Collections.synchronizedSet(new HashSet<IForwardingRulesManagerAware>());
         frmFileName = GlobalConstants.STARTUPHOME.toString() + "frm_staticflows_" + this.getContainerName() + ".conf";
         portGroupFileName = GlobalConstants.STARTUPHOME.toString() + "portgroup_" + this.getContainerName() + ".conf";
 
@@ -2207,6 +2207,7 @@ public class ForwardingRulesManager implements IForwardingRulesManager, PortGrou
      *
      */
     void destroy() {
+        frmAware.clear();
     }
 
     /**
index e3c2189bf91550bd7c8d35526ec0d75413a88a6a..17780fc70db079034f7111c47cf420368f82edd7 100644 (file)
@@ -7,9 +7,7 @@
  */
 package org.opendaylight.controller.subnets.northbound;
 
-import java.util.ArrayList;
 import java.util.HashSet;
-import java.util.List;
 import java.util.Set;
 
 import javax.ws.rs.Consumes;
@@ -159,7 +157,7 @@ public class SubnetsNorthboundJAXRS {
             throw new ResourceNotFoundException(RestMessages.NOCONTAINER.toString());
         }
 
-        SubnetConfig cfgObject = new SubnetConfig(subnetName, subnet, new ArrayList<String>(0));
+        SubnetConfig cfgObject = new SubnetConfig(subnetName, subnet, new HashSet<String>(0));
         Status status = switchManager.addSubnet(cfgObject);
         if (status.isSuccess()) {
             return Response.status(Response.Status.CREATED).build();
@@ -387,7 +385,7 @@ public class SubnetsNorthboundJAXRS {
         } else {
             Status st;
             boolean successful = true;
-            List<String> ports = subnetConf.getNodePorts();
+            Set<String> ports = subnetConf.getNodePorts();
 
             if (action.equals("add")) {
                 // add new ports
index 635a8bce7c3ef847b7c20ff1ee293e140087d05d..3ab38cc41f6db686b273864801c238f3cb36eb11 100644 (file)
@@ -98,7 +98,7 @@ IInventoryShimExternalListener, CommandProvider {
     private ConcurrentMap<Long, Boolean> switchSupportsVendorExtStats;
     // Per port sampled (every portStatsPeriod) transmit rate
     private Map<Long, Map<Short, TxRates>> txRates;
-    private Set<IOFStatisticsListener> statisticsListeners;
+    private Set<IOFStatisticsListener> statisticsListeners = new CopyOnWriteArraySet<IOFStatisticsListener>();
 
     /**
      * The object containing the latest factoredSamples tx rate samples for a
@@ -198,7 +198,6 @@ IInventoryShimExternalListener, CommandProvider {
         switchPortStatsUpdated = new LinkedBlockingQueue<Long>(INITIAL_SIZE);
         switchSupportsVendorExtStats = new ConcurrentHashMap<Long, Boolean>(INITIAL_SIZE);
         txRates = new HashMap<Long, Map<Short, TxRates>>(INITIAL_SIZE);
-        statisticsListeners = new CopyOnWriteArraySet<IOFStatisticsListener>();
 
         configStatsPollIntervals();
 
@@ -252,6 +251,7 @@ IInventoryShimExternalListener, CommandProvider {
      *
      */
     void destroy() {
+        statisticsListeners.clear();
     }
 
     /**
index 84f7dd9282ca89cc67eb160a6465712c2b489d8b..215216e25f00a8fb3f9538d59902d9daa5e86357 100644 (file)
@@ -39,7 +39,7 @@ public class ReadService implements IPluginInReadService, IReadFilterInternalLis
     private static final Logger logger = LoggerFactory
             .getLogger(ReadService.class);
     private IReadServiceFilter filter;
-    private Set<IPluginOutReadService> pluginOutReadServices;
+    private Set<IPluginOutReadService> pluginOutReadServices = new CopyOnWriteArraySet<IPluginOutReadService>();
     private String containerName;
     private IPluginOutConnectionService connectionOutService;
 
@@ -51,9 +51,7 @@ public class ReadService implements IPluginInReadService, IReadFilterInternalLis
     @SuppressWarnings("unchecked")
     void init(Component c) {
         Dictionary<Object, Object> props = c.getServiceProperties();
-        containerName = (props != null) ? (String) props.get("containerName")
-                : null;
-        pluginOutReadServices = new CopyOnWriteArraySet<IPluginOutReadService>();
+        containerName = (props != null) ? (String) props.get("containerName") : null;
     }
 
     /**
@@ -63,6 +61,7 @@ public class ReadService implements IPluginInReadService, IReadFilterInternalLis
      *
      */
     void destroy() {
+        pluginOutReadServices.clear();
     }
 
     /**
index 2c8708f20ee46295972a6b18b280df436f009dfc..b877eb0ee793626d2990e24855052653466aa4ba 100644 (file)
@@ -64,7 +64,8 @@ public class ReadServiceFilter implements IReadServiceFilter, IContainerListener
     private ConcurrentMap<String, Set<Node>> containerToNode;
     private ConcurrentMap<String, Set<NodeTable>> containerToNt;
     private ConcurrentMap<String, Set<ContainerFlow>> containerFlows;
-    private ConcurrentMap<String, IReadFilterInternalListener> readFilterInternalListeners;
+    private ConcurrentMap<String, IReadFilterInternalListener> readFilterInternalListeners =
+        new ConcurrentHashMap<String, IReadFilterInternalListener>();
 
     public void setController(IController core) {
         this.controller = core;
@@ -119,7 +120,6 @@ public class ReadServiceFilter implements IReadServiceFilter, IContainerListener
         containerToNt = new ConcurrentHashMap<String, Set<NodeTable>>();
         containerToNode = new ConcurrentHashMap<String, Set<Node>>();
         containerFlows = new ConcurrentHashMap<String, Set<ContainerFlow>>();
-        readFilterInternalListeners = new ConcurrentHashMap<String, IReadFilterInternalListener>();
     }
 
     /**
@@ -129,6 +129,7 @@ public class ReadServiceFilter implements IReadServiceFilter, IContainerListener
      *
      */
     void destroy() {
+        readFilterInternalListeners.clear();
     }
 
     /**
index 869dc81f8db8993ddf097556c793ff5017a8a64b..bdd546055c22ce29228d587b0a7cc266a7a700e6 100644 (file)
@@ -59,8 +59,10 @@ import org.slf4j.LoggerFactory;
 public class ReadService implements IReadService, CommandProvider, IPluginOutReadService {
 
     protected static final Logger logger = LoggerFactory.getLogger(ReadService.class);
-    private ConcurrentHashMap<String, IPluginInReadService> pluginReader;
-    private Set<IReadServiceListener> readerListeners;
+    private ConcurrentHashMap<String, IPluginInReadService> pluginReader =
+        new ConcurrentHashMap<String, IPluginInReadService>();
+    private Set<IReadServiceListener> readerListeners =
+        new CopyOnWriteArraySet<IReadServiceListener>();
 
     /**
      * Function called by the dependency manager when all the required
@@ -68,8 +70,6 @@ public class ReadService implements IReadService, CommandProvider, IPluginOutRea
      *
      */
     void init() {
-        pluginReader = new ConcurrentHashMap<String, IPluginInReadService>();
-        readerListeners = new CopyOnWriteArraySet<IReadServiceListener>();
     }
 
     /**
@@ -82,6 +82,7 @@ public class ReadService implements IReadService, CommandProvider, IPluginOutRea
         // In case of plugin disactivating make sure we clear the
         // dependencies
         this.pluginReader.clear();
+        this.readerListeners.clear();
     }
 
     /**
index eec183d59573aea1bc7deda423416fd4a27b575b..57dfa91b964956e68336673debbca76288d5a00d 100644 (file)
@@ -170,13 +170,25 @@ public class StatisticsManager implements IStatisticsManager, IReadServiceListen
         // Retrieve current statistics so we don't have to wait for next refresh
         ISwitchManager switchManager = (ISwitchManager) ServiceHelper.getInstance(
                 ISwitchManager.class, container.getName(), this);
-        if (reader != null && switchManager != null) {
+        if ((reader != null) && (switchManager != null)) {
             Set<Node> nodeSet = switchManager.getNodes();
             for (Node node : nodeSet) {
-                flowStatistics.put(node, reader.readAllFlows(node));
-                descriptionStatistics.put(node, reader.readDescription(node));
-                tableStatistics.put(node, reader.readNodeTable(node));
-                nodeConnectorStatistics.put(node, reader.readNodeConnectors(node));
+                List<FlowOnNode> flows = reader.readAllFlows(node);
+                if (flows != null) {
+                    flowStatistics.put(node, flows);
+                }
+                NodeDescription descr = reader.readDescription(node);
+                if (descr != null) {
+                    descriptionStatistics.put(node, descr);
+                }
+                List<NodeTableStatistics> tableStats = reader.readNodeTable(node);
+                if (tableStats != null) {
+                    tableStatistics.put(node, tableStats);
+                }
+                List<NodeConnectorStatistics> ncStats = reader.readNodeConnectors(node);
+                if (ncStats != null) {
+                    nodeConnectorStatistics.put(node, ncStats);
+                }
             }
 
         } else {
index 6a8eea2d0c7e3f75322dbf946bd90d4e190cfed2..55a7ecb9cdd861a96c0f431b86823810d7a548c4 100644 (file)
@@ -56,12 +56,8 @@ public class Subnet implements Cloneable, Serializable {
      * @param sp Set of NodeConnectors to add to the subnet
      */
     public void addNodeConnectors(Set<NodeConnector> sp) {
-        if (sp == null) {
-            return;
-        }
-
-        for (NodeConnector p : sp) {
-            this.nodeConnectors.add(p);
+        if (sp != null) {
+            this.nodeConnectors.addAll(sp);
         }
     }
 
index 52b5f5255d3e5c13f088a38c19819c8730fdf266..4ed9934b27a3f6d3105c2854c86c48f131fe40c6 100644 (file)
@@ -48,13 +48,13 @@ public class SubnetConfig implements Cloneable, Serializable {
     private String subnet; // A.B.C.D/MM  Where A.B.C.D is the Default
                            // Gateway IP (L3) or ARP Querier IP (L2
     @XmlElement
-    private List<String> nodePorts; // datapath ID/port list:
+    private Set<String> nodePorts; // datapath ID/port list:
                                     // xx:xx:xx:xx:xx:xx:xx:xx/a,b,c-m,r-t,y
 
     public SubnetConfig() {
     }
 
-    public SubnetConfig(String desc, String sub, List<String> sp) {
+    public SubnetConfig(String desc, String sub, Set<String> sp) {
         name = desc;
         subnet = sub;
         nodePorts = sp;
@@ -63,14 +63,14 @@ public class SubnetConfig implements Cloneable, Serializable {
     public SubnetConfig(SubnetConfig subnetConfig) {
         name = subnetConfig.name;
         subnet = subnetConfig.subnet;
-        nodePorts = new ArrayList<String>(subnetConfig.nodePorts);
+        nodePorts = new HashSet<String>(subnetConfig.nodePorts);
     }
 
     public String getName() {
         return name;
     }
 
-    public List<String> getNodePorts() {
+    public Set<String> getNodePorts() {
         return nodePorts;
     }
 
index f50f303a3f6b07dd325bc4d488d86092499b61a8..4c4adf047853410d325b5d67fad2c197ef66866e 100644 (file)
@@ -92,7 +92,7 @@ CommandProvider {
     private static final String SAVE = "Save";
     private String subnetFileName, spanFileName, switchConfigFileName;
     private final List<NodeConnector> spanNodeConnectors = new CopyOnWriteArrayList<NodeConnector>();
-    // set of Subnets keyed by the InetAddress
+    // Collection of Subnets keyed by the InetAddress
     private ConcurrentMap<InetAddress, Subnet> subnets;
     private ConcurrentMap<String, SubnetConfig> subnetsConfigList;
     private ConcurrentMap<SpanConfig, SpanConfig> spanConfigList;
@@ -401,19 +401,21 @@ CommandProvider {
                 Set<NodeConnector> sp = conf.getSubnetNodeConnectors();
                 subnet.addNodeConnectors(sp);
             }
-            boolean result = false;
+            boolean putNewSubnet = false;
             if(subnetCurr == null) {
                 if(subnets.putIfAbsent(conf.getIPnum(), subnet) == null) {
-                    result = true;
+                    putNewSubnet = true;
                 }
             } else {
-                result = subnets.replace(conf.getIPnum(), subnetCurr, subnet);
+                putNewSubnet = subnets.replace(conf.getIPnum(), subnetCurr, subnet);
             }
-            if(!result) {
+            if(!putNewSubnet) {
                 String msg = "Cluster conflict: Conflict while adding the subnet " + conf.getIPnum();
                 return new Status(StatusCode.CONFLICT, msg);
             }
-        } else { // This is the deletion of the whole subnet
+
+        // Subnet removal case
+        } else {
             subnets.remove(conf.getIPnum());
         }
         return new Status(StatusCode.SUCCESS);
@@ -435,7 +437,7 @@ CommandProvider {
         return new Status(StatusCode.SUCCESS);
     }
 
-    private Status addRemoveSubnet(SubnetConfig conf, boolean add) {
+    private Status addRemoveSubnet(SubnetConfig conf, boolean isAdding) {
         // Valid config check
         if (!conf.isValidConfig()) {
             String msg = "Invalid Subnet configuration";
@@ -443,13 +445,13 @@ CommandProvider {
             return new Status(StatusCode.BADREQUEST, msg);
         }
 
-        if (add) {
+        if (isAdding) {
             // Presence check
             if (subnetsConfigList.containsKey(conf.getName())) {
                 return new Status(StatusCode.CONFLICT,
-                        "Same subnet config already exists");
+                        "Subnet with the specified name already configured.");
             }
-            // Semantyc check
+            // Semantic check
             Status rc = semanticCheck(conf);
             if (!rc.isSuccess()) {
                 return rc;
@@ -457,13 +459,13 @@ CommandProvider {
         }
 
         // Update Database
-        Status rc = updateDatabase(conf, add);
+        Status rc = updateDatabase(conf, isAdding);
 
         if (rc.isSuccess()) {
             // Update Configuration
-            rc = updateConfig(conf, add);
+            rc = updateConfig(conf, isAdding);
             if(!rc.isSuccess()) {
-                updateDatabase(conf, (!add));
+                updateDatabase(conf, (!isAdding));
             }
         }
 
@@ -512,8 +514,8 @@ CommandProvider {
         Subnet sub = subCurr.clone();
         Set<NodeConnector> sp = confCurr.getNodeConnectors(switchPorts);
         sub.addNodeConnectors(sp);
-        boolean subnetsReplace = subnets.replace(confCurr.getIPnum(), subCurr, sub);
-        if (!subnetsReplace) {
+        boolean subnetsReplaced = subnets.replace(confCurr.getIPnum(), subCurr, sub);
+        if (!subnetsReplaced) {
             String msg = "Cluster conflict: Conflict while adding ports to the subnet " + name;
             return new Status(StatusCode.CONFLICT, msg);
         }
@@ -521,8 +523,8 @@ CommandProvider {
         // Update Configuration
         SubnetConfig conf = confCurr.clone();
         conf.addNodeConnectors(switchPorts);
-        boolean result = subnetsConfigList.replace(name, confCurr, conf);
-        if (!result) {
+        boolean configReplaced = subnetsConfigList.replace(name, confCurr, conf);
+        if (!configReplaced) {
             // TODO: recovery using Transactionality
             String msg = "Cluster conflict: Conflict while adding ports to the subnet " + name;
             return new Status(StatusCode.CONFLICT, msg);
index a233ad4b3ebc556558bed7cc92274d6f465b41c6..d74c3d36308b157f4fa4021c504a01cc083b2627 100644 (file)
@@ -8,7 +8,6 @@
 
 package org.opendaylight.controller.switchmanager.internal;
 
-import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -33,7 +32,7 @@ public class SwitchManagerTest {
         SwitchManager switchmgr = new SwitchManager();
         switchmgr.startUp();
 
-        ArrayList<String> portList = new ArrayList<String>();
+        Set<String> portList = new HashSet<String>();
         portList.add("1/1");
         portList.add("1/2");
         portList.add("1/3");
index ca1dd971378e490b6e096521071d622fe985a38d..37798ac137f36a7a4014dc84c45f523fe2b8d860 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.controller.devices.web;
 
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -438,7 +439,7 @@ public class Devices implements IDaylightWeb {
             ISwitchManager switchManager = (ISwitchManager) ServiceHelper
                     .getInstance(ISwitchManager.class, containerName, this);
             SubnetConfig cfgObject = new SubnetConfig(gatewayName,
-                    gatewayIPAddress, new ArrayList<String>());
+                    gatewayIPAddress, new HashSet<String>());
             Status result = switchManager.addSubnet(cfgObject);
             if (result.isSuccess()) {
                 resultBean.setStatus(true);