ISSUE 96/96/1
authorAlessandro Boch <aboch@cisco.com>
Tue, 2 Apr 2013 21:05:14 +0000 (14:05 -0700)
committerAlessandro Boch <aboch@cisco.com>
Tue, 2 Apr 2013 21:05:14 +0000 (14:05 -0700)
Opendaylight controller to get node description from OF description
statistics datapath description field

CHANGE
- Switch Mgr to expose a getNodeDescription() method which returns the
  description configured by user if any, otherwise the one learnt from
  the proto plugin
- Web bunldes to make use of the above api (Currently they are ignoring
  the info learnt by the plugin)
- OFStatisticsManager to implement a IStatistics interface for informing
  listeners that the description statistics info has been refreshed
- Removing current logic where OFStatisticsManager was explicitely
  invoking the description property update on InventoryService through
  IOFInventoryService
- Removed logic where InventoryServiceShim queries OFStatisticsManager
  about node description as information is not available at that time
  and IStatisticsListener updates will serve same purpose
- Removing statistics request timeouts from OFStatisticsManager as the
  timeout is compeltely handled by core.internal.StatisticsCollector

Change-Id: I0d2941d3012ca6dc77a386570dbbd8e5c7832a03
Signed-off-by: Alessandro Boch <aboch@cisco.com>
36 files changed:
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/IInventoryShimInternalListener.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/IOFInventoryService.java [deleted file]
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/IOFStatisticsManager.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/IStatisticsListener.java [new file with mode: 0644]
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/Activator.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DescStatisticsConverter.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/OFStatisticsManager.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/ReadServiceFilter.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/TopologyServiceShim.java
opendaylight/routing/dijkstra_implementation/src/main/java/org/opendaylight/controller/routing/dijkstra_implementation/internal/DijkstraImplementation.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/action/ActionType.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Description.java [new file with mode: 0644]
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Name.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Node.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/NodeConnector.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/flowprogrammer/Flow.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/inventory/IListenInventoryUpdates.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/inventory/IPluginOutInventoryService.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/match/Match.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/match/MatchField.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/match/MatchType.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/reader/NodeDescription.java
opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/action/ActionTest.java
opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/reader/NodeDescriptionTest.java
opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/IInventoryListener.java
opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/ISwitchManager.java
opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/SubnetConfig.java
opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/SwitchConfig.java
opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java
opendaylight/switchmanager/src/test/java/org/opendaylight/controller/switchmanager/SwitchTest.java
opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/Devices.java
opendaylight/web/flows/src/main/java/org/opendaylight/controller/flows/web/Flows.java
opendaylight/web/topology/src/main/java/org/opendaylight/controller/topology/web/Topology.java
opendaylight/web/troubleshoot/src/main/java/org/opendaylight/controller/troubleshoot/web/Troubleshoot.java

index 50a4bca..e7c11a6 100644 (file)
@@ -29,7 +29,7 @@ public interface IInventoryShimInternalListener {
      * @param node                     {@link org.opendaylight.controller.sal.core.Node} being updated
      * @param type             {@link org.opendaylight.controller.sal.core.UpdateType}
      * @param props            set of {@link org.opendaylight.controller.sal.core.Property} such as
-     *                                                 {@link org.opendaylight.controller.sal.core.Name} and/or
+     *                                                 {@link org.opendaylight.controller.sal.core.Description} and/or
      *                                                 {@link org.opendaylight.controller.sal.core.Tier} etc.
      */
     public void updateNode(Node node, UpdateType type, Set<Property> props);
@@ -40,7 +40,7 @@ public interface IInventoryShimInternalListener {
      * @param nodeConnector    {@link org.opendaylight.controller.sal.core.NodeConnector} being updated
      * @param type             {@link org.opendaylight.controller.sal.core.UpdateType}
      * @param props            set of {@link org.opendaylight.controller.sal.core.Property} such as
-     *                                                 {@link org.opendaylight.controller.sal.core.Name} and/or
+     *                                                 {@link org.opendaylight.controller.sal.core.Description} and/or
      *                                                 {@link org.opendaylight.controller.sal.core.State} etc.
      */
     public void updateNodeConnector(NodeConnector nodeConnector,
diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/IOFInventoryService.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/IOFInventoryService.java
deleted file mode 100644 (file)
index f46f24d..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-
-/*
- * Copyright (c) 2013 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,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.protocol_plugin.openflow;
-
-import java.util.Set;
-
-import org.opendaylight.controller.sal.core.Property;
-
-/**
- *
- * Interface for Inventory Service visible inside the protocol plugin only
- *
- *
- *
- */
-public interface IOFInventoryService {
-    /**
-     * Tell Inventory Service a property has been updated
-     * for the specified switch with the specified value
-     *
-     * @param switchId
-     */
-    public void updateSwitchProperty(Long switchId, Set<Property> propertySet);
-}
index 36bed4f..18fe686 100644 (file)
@@ -86,7 +86,7 @@ public interface IOFStatisticsManager {
      * @return the list of openflow statistics
      */
     List<OFStatistics> queryStatistics(Long switchId,
-            OFStatisticsType statType, Object target, long timeout);
+            OFStatisticsType statType, Object target);
 
     /**
      * Returns the averaged transmit rate for the passed switch port
diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/IStatisticsListener.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/IStatisticsListener.java
new file mode 100644 (file)
index 0000000..4f15a10
--- /dev/null
@@ -0,0 +1,13 @@
+package org.opendaylight.controller.protocol_plugin.openflow;
+
+import org.openflow.protocol.statistics.OFDescriptionStatistics;
+
+/**
+ * Interface which defines the api which gets called when the information
+ * contained in the OF description statistics reply message from a network
+ * is updated with new one.
+ */
+public interface IStatisticsListener {
+       public void descriptionRefreshed(Long switchId,
+                                       OFDescriptionStatistics description);
+}
index 75ba174..45c0211 100644 (file)
@@ -9,7 +9,6 @@
 
 package org.opendaylight.controller.protocol_plugin.openflow.internal;
 
-import org.opendaylight.controller.sal.core.IContainerListener;
 import java.util.Dictionary;
 import java.util.Hashtable;
 
@@ -18,18 +17,16 @@ import org.opendaylight.controller.protocol_plugin.openflow.IDataPacketListen;
 import org.opendaylight.controller.protocol_plugin.openflow.IDataPacketMux;
 import org.opendaylight.controller.protocol_plugin.openflow.IInventoryShimExternalListener;
 import org.opendaylight.controller.protocol_plugin.openflow.IInventoryShimInternalListener;
-import org.opendaylight.controller.protocol_plugin.openflow.IOFInventoryService;
 import org.opendaylight.controller.protocol_plugin.openflow.IOFStatisticsManager;
 import org.opendaylight.controller.protocol_plugin.openflow.IPluginReadServiceFilter;
 import org.opendaylight.controller.protocol_plugin.openflow.IRefreshInternalProvider;
+import org.opendaylight.controller.protocol_plugin.openflow.IStatisticsListener;
 import org.opendaylight.controller.protocol_plugin.openflow.ITopologyServiceShimListener;
 import org.opendaylight.controller.protocol_plugin.openflow.core.IController;
 import org.opendaylight.controller.protocol_plugin.openflow.core.internal.Controller;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
+import org.opendaylight.controller.sal.core.IContainerListener;
+import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.discovery.IDiscoveryService;
 import org.opendaylight.controller.sal.flowprogrammer.IPluginInFlowProgrammerService;
 import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
@@ -40,6 +37,8 @@ import org.opendaylight.controller.sal.reader.IPluginInReadService;
 import org.opendaylight.controller.sal.topology.IPluginInTopologyService;
 import org.opendaylight.controller.sal.topology.IPluginOutTopologyService;
 import org.opendaylight.controller.sal.utils.GlobalConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Openflow protocol plugin Activator
@@ -117,7 +116,7 @@ public class Activator extends ComponentActivatorAbstractBase {
             // export the service
             c.setInterface(new String[] {
                     IPluginInInventoryService.class.getName(),
-                    IOFInventoryService.class.getName(),
+                    IStatisticsListener.class.getName(),
                     IInventoryShimInternalListener.class.getName() }, null);
 
             // Now lets add a service dependency to make sure the
@@ -239,6 +238,10 @@ public class Activator extends ComponentActivatorAbstractBase {
             c.add(createServiceDependency().setService(IController.class,
                     "(name=Controller)").setCallbacks("setController",
                     "unsetController").setRequired(true));
+            c.add(createServiceDependency().setService(
+                       IStatisticsListener.class)
+                       .setCallbacks("setStatisticsListener",
+                    "unsetStatisticsListener").setRequired(false));
         }
 
         if (imp.equals(DiscoveryService.class)) {
@@ -299,10 +302,6 @@ public class Activator extends ComponentActivatorAbstractBase {
                     IInventoryShimExternalListener.class).setCallbacks(
                     "setInventoryShimExternalListener",
                     "unsetInventoryShimExternalListener").setRequired(false));
-            c.add(createServiceDependency().setService(
-                    IOFStatisticsManager.class).setCallbacks(
-                    "setStatisticsManager", "unsetStatisticsManager")
-                    .setRequired(false));
         }
 
         if (imp.equals(TopologyServiceShim.class)) {
index 33918c5..7a09a48 100644 (file)
@@ -38,7 +38,7 @@ public class DescStatisticsConverter {
             hwDesc.setManufacturer(ofDesc.getManufacturerDescription());
             hwDesc.setHardware(ofDesc.getHardwareDescription());
             hwDesc.setSoftware(ofDesc.getSoftwareDescription());
-            hwDesc.setSdnProtocolDescription(ofDesc.getDatapathDescription());
+            hwDesc.setDescription(ofDesc.getDatapathDescription());
             hwDesc.setSerialNumber(ofDesc.getSerialNumber());
         }
         return hwDesc;
index 7041f44..e713259 100644 (file)
@@ -21,26 +21,27 @@ import java.util.concurrent.ConcurrentMap;
 
 import org.apache.felix.dm.Component;
 import org.opendaylight.controller.protocol_plugin.openflow.IInventoryShimInternalListener;
-import org.opendaylight.controller.protocol_plugin.openflow.IOFInventoryService;
+import org.opendaylight.controller.protocol_plugin.openflow.IStatisticsListener;
 import org.opendaylight.controller.protocol_plugin.openflow.core.IController;
 import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitch;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
+import org.opendaylight.controller.sal.core.Actions;
+import org.opendaylight.controller.sal.core.Buffers;
+import org.opendaylight.controller.sal.core.Capabilities;
 import org.opendaylight.controller.sal.core.ConstructionException;
+import org.opendaylight.controller.sal.core.Description;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.Node.NodeIDType;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.core.Property;
-import org.opendaylight.controller.sal.core.TimeStamp;
 import org.opendaylight.controller.sal.core.Tables;
-import org.opendaylight.controller.sal.core.Actions;
-import org.opendaylight.controller.sal.core.Buffers;
-import org.opendaylight.controller.sal.core.Capabilities;
+import org.opendaylight.controller.sal.core.TimeStamp;
 import org.opendaylight.controller.sal.core.UpdateType;
 import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
 import org.opendaylight.controller.sal.inventory.IPluginOutInventoryService;
 import org.opendaylight.controller.sal.utils.GlobalConstants;
+import org.openflow.protocol.statistics.OFDescriptionStatistics;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * The class describes inventory service protocol plugin. One instance per
@@ -51,7 +52,7 @@ import org.opendaylight.controller.sal.utils.GlobalConstants;
  *
  */
 public class InventoryService implements IInventoryShimInternalListener,
-        IPluginInInventoryService, IOFInventoryService {
+        IPluginInInventoryService, IStatisticsListener {
     protected static final Logger logger = LoggerFactory
             .getLogger(InventoryService.class);
     private Set<IPluginOutInventoryService> pluginOutInventoryServices = Collections
@@ -224,31 +225,31 @@ public class InventoryService implements IInventoryShimInternalListener,
                 + type.getName() + " for Node id "
                 + nodeConnector.getNode().getID());
 
-        if (nodeConnectorProps == null)
+        if (nodeConnectorProps == null) {
             return;
+        }
+
+
+        Map<String, Property> propMap = nodeConnectorProps
+                .get(nodeConnector);
+        switch (type) {
+        case ADDED:
+        case CHANGED:
+            if (propMap == null)
+                propMap = new HashMap<String, Property>();
 
-        synchronized (nodeConnectorProps) {
-            Map<String, Property> propMap = nodeConnectorProps
-                    .get(nodeConnector);
-            switch (type) {
-            case ADDED:
-            case CHANGED:
-                if (propMap == null)
-                    propMap = new HashMap<String, Property>();
-
-                if (props != null) {
-                    for (Property prop : props) {
-                        propMap.put(prop.getName(), prop);
-                    }
+            if (props != null) {
+                for (Property prop : props) {
+                    propMap.put(prop.getName(), prop);
                 }
-                nodeConnectorProps.put(nodeConnector, propMap);
-                break;
-            case REMOVED:
-                nodeConnectorProps.remove(nodeConnector);
-                break;
-            default:
-                return;
             }
+            nodeConnectorProps.put(nodeConnector, propMap);
+            break;
+        case REMOVED:
+            nodeConnectorProps.remove(nodeConnector);
+            break;
+        default:
+            return;
         }
 
         // update sal and discovery
@@ -305,27 +306,33 @@ public class InventoryService implements IInventoryShimInternalListener,
         }
     }
 
-    /*
-     * Function called by other protocol plugin modules to notify Inventory Service
-     * that a property has changed for the specified switch
-     */
-    @Override
-    public void updateSwitchProperty(Long switchId, Set<Property> propSet) {
+
+    private void updateSwitchProperty(Long switchId, Set<Property> propSet) {
         // update local cache
-        Node node = OFSwitchToNode(controller.getSwitches().get(switchId));
+        Node node = OFSwitchToNode(controller.getSwitch(switchId));
         Map<String, Property> propMap = nodeProps.get(node);
-        if (propMap == null)
+        if (propMap == null) {
             propMap = new HashMap<String, Property>();
+        }
+        
+        boolean change = false;
         for (Property prop : propSet) {
-            propMap.put(prop.getName(), prop);
+               String propertyName = prop.getName();
+               Property currentProp = propMap.get(propertyName);
+               if (!prop.equals(currentProp)) {
+                       change = true;
+                       propMap.put(propertyName, prop);
+               }
         }
         nodeProps.put(node, propMap);
 
-        // update sal
-        synchronized (pluginOutInventoryServices) {
-            for (IPluginOutInventoryService service : pluginOutInventoryServices) {
-                service.updateNode(node, UpdateType.CHANGED, propSet);
-            }
+        // Update sal if any of the properties has changed
+        if (change) {
+               synchronized (pluginOutInventoryServices) {
+                   for (IPluginOutInventoryService service : pluginOutInventoryServices) {
+                       service.updateNode(node, UpdateType.CHANGED, propSet);
+                   }
+               }
         }
     }
 
@@ -342,4 +349,15 @@ public class InventoryService implements IInventoryShimInternalListener,
             break;
         }
     }
+
+       @Override
+       public void descriptionRefreshed(Long switchId,
+                       OFDescriptionStatistics descriptionStats) {
+               
+               Set<Property> propSet = new HashSet<Property>(1);
+               Description desc = 
+                               new Description(descriptionStats.getDatapathDescription());
+       propSet.add(desc);
+       this.updateSwitchProperty(switchId, propSet);
+       }
 }
index cd05f31..8d157ac 100644 (file)
@@ -20,35 +20,30 @@ import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.opendaylight.controller.protocol_plugin.openflow.IInventoryShimExternalListener;
 import org.opendaylight.controller.protocol_plugin.openflow.IInventoryShimInternalListener;
-import org.opendaylight.controller.protocol_plugin.openflow.IOFStatisticsManager;
 import org.opendaylight.controller.protocol_plugin.openflow.core.IController;
 import org.opendaylight.controller.protocol_plugin.openflow.core.IMessageListener;
 import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitch;
 import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitchStateListener;
-import org.openflow.protocol.OFMessage;
-import org.openflow.protocol.OFPortStatus;
-import org.openflow.protocol.OFPortStatus.OFPortReason;
-import org.openflow.protocol.OFType;
-import org.openflow.protocol.statistics.OFDescriptionStatistics;
-import org.openflow.protocol.statistics.OFStatistics;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import org.opendaylight.controller.sal.core.Actions;
 import org.opendaylight.controller.sal.core.Buffers;
 import org.opendaylight.controller.sal.core.Capabilities;
 import org.opendaylight.controller.sal.core.ConstructionException;
 import org.opendaylight.controller.sal.core.ContainerFlow;
 import org.opendaylight.controller.sal.core.IContainerListener;
-import org.opendaylight.controller.sal.core.Name;
 import org.opendaylight.controller.sal.core.Node;
-import org.opendaylight.controller.sal.core.Tables;
 import org.opendaylight.controller.sal.core.Node.NodeIDType;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.core.Property;
+import org.opendaylight.controller.sal.core.Tables;
 import org.opendaylight.controller.sal.core.TimeStamp;
 import org.opendaylight.controller.sal.core.UpdateType;
 import org.opendaylight.controller.sal.utils.GlobalConstants;
+import org.openflow.protocol.OFMessage;
+import org.openflow.protocol.OFPortStatus;
+import org.openflow.protocol.OFPortStatus.OFPortReason;
+import org.openflow.protocol.OFType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * The class describes a shim layer that bridges inventory events from Openflow
@@ -65,7 +60,6 @@ public class InventoryServiceShim implements IContainerListener,
     private ConcurrentMap<String, IInventoryShimInternalListener> inventoryShimInternalListeners = new ConcurrentHashMap<String, IInventoryShimInternalListener>();
     private List<IInventoryShimExternalListener> inventoryShimExternalListeners = new CopyOnWriteArrayList<IInventoryShimExternalListener>();
     private ConcurrentMap<NodeConnector, List<String>> containerMap = new ConcurrentHashMap<NodeConnector, List<String>>();
-    private IOFStatisticsManager statsMgr;
 
     void setController(IController s) {
         this.controller = s;
@@ -77,16 +71,6 @@ public class InventoryServiceShim implements IContainerListener,
         }
     }
 
-    void setStatisticsManager(IOFStatisticsManager s) {
-        this.statsMgr = s;
-    }
-
-    void unsetStatisticsManager(IOFStatisticsManager s) {
-        if (this.statsMgr == s) {
-            this.statsMgr = null;
-        }
-    }
-
     void setInventoryShimInternalListener(Map<?, ?> props,
             IInventoryShimInternalListener s) {
         if (props == null) {
@@ -99,7 +83,7 @@ public class InventoryServiceShim implements IContainerListener,
             return;
         }
         if ((this.inventoryShimInternalListeners != null)
-                && !this.inventoryShimInternalListeners.containsKey(s)) {
+                && !this.inventoryShimInternalListeners.containsValue(s)) {
             this.inventoryShimInternalListeners.put(containerName, s);
             logger.trace("Added inventoryShimInternalListener for container:"
                     + containerName);
@@ -118,7 +102,10 @@ public class InventoryServiceShim implements IContainerListener,
             return;
         }
         if ((this.inventoryShimInternalListeners != null)
-                && this.inventoryShimInternalListeners.containsKey(s)) {
+                && this.inventoryShimInternalListeners
+                       .get(containerName) != null
+                && this.inventoryShimInternalListeners
+                       .get(containerName).equals(s)) {
             this.inventoryShimInternalListeners.remove(containerName);
             logger
                     .trace("Removed inventoryShimInternalListener for container: "
@@ -390,16 +377,6 @@ public class InventoryServiceShim implements IContainerListener,
                 .getTime();
         props.add(new TimeStamp(connectedSinceTime, "connectedSince"));
 
-        String name = "";
-        if (statsMgr != null && statsMgr.getOFDescStatistics(sid) != null) {
-            List<OFStatistics> stats = statsMgr.getOFDescStatistics(sid);
-            if (stats.size() > 0) {
-                name = ((OFDescriptionStatistics) stats.get(0))
-                        .getSerialNumber();
-            }
-        }
-        props.add(new Name(name));
-        
         byte tables = sw.getTables();
         Tables t = new Tables(tables);
         if (t != null) {
index bd31f8b..bc61f3b 100644 (file)
@@ -30,13 +30,18 @@ import java.util.concurrent.LinkedBlockingQueue;
 import org.eclipse.osgi.framework.console.CommandInterpreter;
 import org.eclipse.osgi.framework.console.CommandProvider;
 import org.opendaylight.controller.protocol_plugin.openflow.IInventoryShimExternalListener;
-import org.opendaylight.controller.protocol_plugin.openflow.IOFInventoryService;
 import org.opendaylight.controller.protocol_plugin.openflow.IOFStatisticsManager;
+import org.opendaylight.controller.protocol_plugin.openflow.IStatisticsListener;
 import org.opendaylight.controller.protocol_plugin.openflow.core.IController;
 import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitch;
 import org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension.V6Match;
 import org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension.V6StatsReply;
 import org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension.V6StatsRequest;
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.core.Property;
+import org.opendaylight.controller.sal.core.UpdateType;
+import org.opendaylight.controller.sal.utils.HexEncode;
 import org.openflow.protocol.OFError;
 import org.openflow.protocol.OFMatch;
 import org.openflow.protocol.OFPort;
@@ -57,22 +62,10 @@ import org.osgi.framework.FrameworkUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import org.opendaylight.controller.sal.core.Name;
-import org.opendaylight.controller.sal.core.Node;
-import org.opendaylight.controller.sal.core.NodeConnector;
-import org.opendaylight.controller.sal.core.Property;
-import org.opendaylight.controller.sal.core.UpdateType;
-import org.opendaylight.controller.sal.utils.GlobalConstants;
-import org.opendaylight.controller.sal.utils.HexEncode;
-import org.opendaylight.controller.sal.utils.ServiceHelper;
-
 /**
  * It periodically polls the different OF statistics from the OF switches
  * and caches them for quick retrieval for the above layers' modules
  * It also provides an API to directly query the switch about the statistics
- *
- *
- *
  */
 public class OFStatisticsManager implements IOFStatisticsManager,
         IInventoryShimExternalListener, CommandProvider {
@@ -82,7 +75,6 @@ public class OFStatisticsManager implements IOFStatisticsManager,
     private static final long flowStatsPeriod = 10000;
     private static final long descriptionStatsPeriod = 60000;
     private static final long portStatsPeriod = 5000;
-    private long statisticsTimeout = 4000;
     private static final long tickPeriod = 1000;
     private static short statisticsTickNumber = (short) (flowStatsPeriod / tickPeriod);
     private static short descriptionTickNumber = (short) (descriptionStatsPeriod / tickPeriod);
@@ -102,8 +94,8 @@ public class OFStatisticsManager implements IOFStatisticsManager,
     private Timer statisticsTimer;
     private TimerTask statisticsTimerTask;
     private ConcurrentMap<Long, Boolean> switchSupportsVendorExtStats;
-    private Map<Long, String> switchNamesDB;
     private Map<Long, Map<Short, TxRates>> txRates; // Per port sampled (every portStatsPeriod) transmit rate
+    private Set<IStatisticsListener> descriptionListeners;
 
     /**
      * The object containing the latest factoredSamples tx rate samples
@@ -166,54 +158,10 @@ public class OFStatisticsManager implements IOFStatisticsManager,
      *
      */
     void init() {
-    }
-
-    /**
-     * 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() {
-    }
-
-    /**
-     * Function called by dependency manager after "init ()" is called
-     * and after the services provided by the class are registered in
-     * the service registry
-     *
-     */
-    void start() {
-        // Start managed timers
-        statisticsTimer.scheduleAtFixedRate(statisticsTimerTask, 0, tickPeriod);
-
-        // Start statistics collector thread
-        statisticsCollector.start();
-
-        // Start bandwidth utilization computer thread
-        txRatesUpdater.start();
-
-        // OSGI console
-        registerWithOSGIConsole();
-    }
-
-    /**
-     * Function called by the dependency manager before the services
-     * exported by the component are unregistered, this will be
-     * followed by a "destroy ()" calls
-     *
-     */
-    void stop() {
-        // Stop managed timers
-        statisticsTimer.cancel();
-    }
-
-    public OFStatisticsManager() {
-        flowStatistics = new ConcurrentHashMap<Long, List<OFStatistics>>();
+       flowStatistics = new ConcurrentHashMap<Long, List<OFStatistics>>();
         descStatistics = new ConcurrentHashMap<Long, List<OFStatistics>>();
         portStatistics = new ConcurrentHashMap<Long, List<OFStatistics>>();
         dummyList = new ArrayList<OFStatistics>(1);
-        switchNamesDB = new HashMap<Long, String>();
         statisticsTimerTicks = new ConcurrentHashMap<Long, StatisticsTicks>(
                 initialSize);
         pendingStatsRequests = new LinkedBlockingQueue<StatsRequest>(
@@ -222,6 +170,7 @@ public class OFStatisticsManager implements IOFStatisticsManager,
         switchSupportsVendorExtStats = new ConcurrentHashMap<Long, Boolean>(
                 initialSize);
         txRates = new HashMap<Long, Map<Short, TxRates>>(initialSize);
+        descriptionListeners = new HashSet<IStatisticsListener>();
 
         // Initialize managed timers
         statisticsTimer = new Timer();
@@ -239,11 +188,10 @@ public class OFStatisticsManager implements IOFStatisticsManager,
                 while (true) {
                     try {
                         StatsRequest req = pendingStatsRequests.take();
-                        acquireStatistics(req.switchId, req.type,
-                                statisticsTimeout);
+                        acquireStatistics(req.switchId, req.type);
                     } catch (InterruptedException e) {
-                        log
-                                .warn("Flow Statistics Collector thread interrupted");
+                        log.warn("Flow Statistics Collector thread " +
+                                       "interrupted");
                     }
                 }
             }
@@ -263,9 +211,58 @@ public class OFStatisticsManager implements IOFStatisticsManager,
                 }
             }
         }, "TX Rate Updater");
+    }
 
+    /**
+     * 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() {
     }
 
+    /**
+     * Function called by dependency manager after "init ()" is called
+     * and after the services provided by the class are registered in
+     * the service registry
+     *
+     */
+    void start() {
+        // Start managed timers
+        statisticsTimer.scheduleAtFixedRate(statisticsTimerTask, 0, tickPeriod);
+
+        // Start statistics collector thread
+        statisticsCollector.start();
+
+        // Start bandwidth utilization computer thread
+        txRatesUpdater.start();
+
+        // OSGI console
+        registerWithOSGIConsole();
+    }
+
+    /**
+     * Function called by the dependency manager before the services
+     * exported by the component are unregistered, this will be
+     * followed by a "destroy ()" calls
+     *
+     */
+    void stop() {
+        // Stop managed timers
+        statisticsTimer.cancel();
+    }
+
+    public void setStatisticsListener(IStatisticsListener s) {
+       this.descriptionListeners.add(s);
+    }
+    
+    public void unsetStatisticsListener(IStatisticsListener s) {
+       if (s != null) {
+               this.descriptionListeners.remove(s);
+       }
+    }
+    
     private void registerWithOSGIConsole() {
         BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass())
                 .getBundleContext();
@@ -456,12 +453,11 @@ public class OFStatisticsManager implements IOFStatisticsManager,
                 + HexString.toHexString(switchId));
     }
 
-    private void acquireStatistics(Long switchId, OFStatisticsType statType,
-            long timeout) {
+    private void acquireStatistics(Long switchId, OFStatisticsType statType) {
 
         // Query the switch on all matches
         List<OFStatistics> values = this.acquireStatistics(switchId, statType,
-                null, timeout);
+                null);
 
         // Update local caching database if got a valid response
         if (values != null && !values.isEmpty()) {
@@ -469,31 +465,10 @@ public class OFStatisticsManager implements IOFStatisticsManager,
                     || (statType == OFStatisticsType.VENDOR)) {
                 flowStatistics.put(switchId, values);
             } else if (statType == OFStatisticsType.DESC) {
-                if ((switchNamesDB != null)
-                        && switchNamesDB.containsKey(switchId)) {
-                    // Check if user manually configured a name for the switch
-                    for (OFStatistics entry : values) {
-                        OFDescriptionStatistics reply = (OFDescriptionStatistics) entry;
-                        reply.setSerialNumber(switchNamesDB.get(switchId));
-                    }
-                }
-                // check if notification is needed
-                if (descStatistics.get(switchId) == null
-                        || !(descStatistics.get(switchId).get(0).equals(values
-                                .get(0)))) {
-                    IOFInventoryService inventory = (IOFInventoryService) ServiceHelper
-                            .getInstance(IOFInventoryService.class,
-                                    GlobalConstants.DEFAULT.toString(), this);
-                    if (inventory != null) {
-                        // Notify Inventory Service about the name update
-                        Set<Property> propSet = new HashSet<Property>(1);
-                        Name name = new Name(((OFDescriptionStatistics) values
-                                .get(0)).getSerialNumber());
-                        propSet.add(name);
-                        inventory.updateSwitchProperty(switchId, propSet);
-                    }
-                }
-                // overwrite cache
+               // Notify who may be interested in a description change
+                       notifyDescriptionListeners(switchId, values);
+               
+                // Overwrite cache
                 descStatistics.put(switchId, values);
             } else if (statType == OFStatisticsType.PORT) {
                 // Overwrite cache with new port statistics for this switch
@@ -505,12 +480,20 @@ public class OFStatisticsManager implements IOFStatisticsManager,
         }
     }
 
+    private void notifyDescriptionListeners(Long switchId,
+                                                               List<OFStatistics> values) {
+               for (IStatisticsListener l : this.descriptionListeners) {
+                       l.descriptionRefreshed(switchId, 
+                                       ((OFDescriptionStatistics)values.get(0)));
+               }
+    }
+    
     /*
      * Generic function to get the statistics form a OF switch
      */
     @SuppressWarnings("unchecked")
     private List<OFStatistics> acquireStatistics(Long switchId,
-            OFStatisticsType statsType, Object target, long timeout) {
+            OFStatisticsType statsType, Object target) {
         List<OFStatistics> values = null;
         String type = null;
         ISwitch sw = controller.getSwitch(switchId);
@@ -742,7 +725,7 @@ public class OFStatisticsManager implements IOFStatisticsManager,
 
     @Override
     public List<OFStatistics> queryStatistics(Long switchId,
-            OFStatisticsType statType, Object target, long timeout) {
+            OFStatisticsType statType, Object target) {
         /*
          * Caller does not know and it is not supposed to know whether
          * this switch supports vendor extension. We adjust the target for him
@@ -754,7 +737,7 @@ public class OFStatisticsManager implements IOFStatisticsManager,
         }
 
         List<OFStatistics> list = this.acquireStatistics(switchId, statType,
-                target, timeout);
+                target);
 
         return (list == null) ? null
                 : (statType == OFStatisticsType.VENDOR) ? v6StatsListToOFStatsList(list)
@@ -877,17 +860,9 @@ public class OFStatisticsManager implements IOFStatisticsManager,
     @Override
     public String getHelp() {
         StringBuffer help = new StringBuffer();
-        help.append("---OF Switch ID to Name Mapping---\n");
-        help
-                .append("\t ofaddname              - Add a switchId to name mapping entry\n");
-        help
-                .append("\t ofdeletename           - Delete a switchId from the mapping db\n");
-        help.append("\t ofprintnames           - Print the mapping db\n");
         help.append("---OF Statistics Manager utilities---\n");
-        help
-                .append("\t ofdumpstatsmgr         - Print Internal Stats Mgr db\n");
-        help
-                .append("\t ofstatstimeout         - Change Statistics request's timeout value\n");
+        help.append("\t ofdumpstatsmgr         - " + 
+                               "Print Internal Stats Mgr db\n");
         return help.toString();
     }
 
@@ -918,43 +893,6 @@ public class OFStatisticsManager implements IOFStatisticsManager,
         return Long.parseLong(switchString, radix);
     }
 
-    public void _ofaddname(CommandInterpreter ci) {
-        if (switchNamesDB == null)
-            switchNamesDB = new HashMap<Long, String>();
-        String switchId = ci.nextArgument();
-        if (!isValidSwitchId(switchId)) {
-            ci.println("Please provide a valid SwithcId");
-            return;
-        }
-        Long sid = getSwitchIDLong(switchId);
-        String switchName = ci.nextArgument();
-        if (switchName == null) {
-            ci.println("Please provide a valid Switch name");
-            return;
-        }
-        switchNamesDB.put(sid, switchName);
-    }
-
-    public void _ofdeletename(CommandInterpreter ci) {
-        if (switchNamesDB == null)
-            return;
-        String switchId = ci.nextArgument();
-        if (!isValidSwitchId(switchId)) {
-            ci.println("Please provide a valid SwitchId");
-            return;
-        }
-        Long sid = getSwitchIDLong(switchId);
-        switchNamesDB.remove(sid);
-    }
-
-    public void _ofprintnames(CommandInterpreter ci) {
-        if (switchNamesDB == null)
-            return;
-        for (Long key : switchNamesDB.keySet()) {
-            ci.println(key + " -> " + switchNamesDB.get(key) + "\n");
-        }
-    }
-
     /*
      * Internal information dump code
      */
@@ -983,24 +921,6 @@ public class OFStatisticsManager implements IOFStatisticsManager,
         ci.println("Flow Stats Period: " + statisticsTickNumber + " s");
         ci.println("Desc Stats Period: " + descriptionTickNumber + " s");
         ci.println("Port Stats Period: " + portTickNumber + " s");
-        ci.println("Stats request timeout: " + Float.valueOf(statisticsTimeout)
-                / 1000.0 + " s");
-    }
-
-    public void _ofstatstimeout(CommandInterpreter ci) {
-        String timeoutString = ci.nextArgument();
-        if (timeoutString == null || !timeoutString.matches("^[0-9]+$")) {
-            ci.println("Invalid value. Has to be numeric.");
-            return;
-        }
-
-        long newTimeout = Long.valueOf(timeoutString);
-        if (newTimeout < 50 || newTimeout > 60000) {
-            ci.println("Invalid value. Valid range is [50-60000]ms");
-            return;
-        }
-        this.statisticsTimeout = newTimeout;
-        ci.println("New value: " + statisticsTimeout + " ms");
     }
 
     public void _resetSwitchCapability(CommandInterpreter ci) {
@@ -1053,10 +973,9 @@ public class OFStatisticsManager implements IOFStatisticsManager,
         String averageWindow = ci.nextArgument();
         short seconds = 0;
         if (averageWindow == null) {
-            ci
-                    .println("Insert the length in seconds of the average window for tx rate");
-            ci
-                    .println("Current: " + factoredSamples * portTickNumber
+            ci.println("Insert the length in seconds of the median " + 
+                       "window for tx rate");
+            ci.println("Current: " + factoredSamples * portTickNumber
                             + " secs");
             return;
         }
@@ -1065,8 +984,40 @@ public class OFStatisticsManager implements IOFStatisticsManager,
         } catch (NumberFormatException e) {
             ci.println("Invalid period.");
         }
-        OFStatisticsManager.factoredSamples = (short) (seconds / portTickNumber);
+        OFStatisticsManager.factoredSamples = (short) (seconds/portTickNumber);
         ci.println("New: " + factoredSamples * portTickNumber + " secs");
     }
 
+    public void _ofstatsmgrintervals(CommandInterpreter ci) {
+        String flowStatsInterv = ci.nextArgument();
+        String portStatsInterv = ci.nextArgument();
+        
+        if (flowStatsInterv == null || portStatsInterv == null) {
+
+            ci.println("Usage: ostatsmgrintervals <fP> <pP> (in seconds)");
+            ci.println("Current Values: fP=" + statisticsTickNumber +
+                       "s pP=" + portTickNumber + "s");
+            return;
+        }
+        Short fP, pP;
+        try {
+               fP = Short.parseShort(flowStatsInterv);
+               pP = Short.parseShort(portStatsInterv);
+        } catch (Exception e) {
+               ci.println("Invalid format values: " + e.getMessage());
+               return;
+        }
+
+        if (pP <= 1 || fP <=1) {
+               ci.println("Invalid values. fP and pP have to be greater than 1.");
+               return;
+        }
+        
+        statisticsTickNumber = fP;
+        portTickNumber = pP;
+        
+        ci.println("New Values: fP=" + statisticsTickNumber +
+                       "s pP=" + portTickNumber + "s");
+    }
+
 }
index 4301bfd..1b71c3b 100644 (file)
@@ -128,7 +128,7 @@ public class ReadServiceFilter implements IPluginReadServiceFilter,
         OFMatch ofMatch = new FlowConverter(flow).getOFMatch();
         List<OFStatistics> ofList = (cached == true) ? statsMgr
                 .getOFFlowStatistics(sid, ofMatch) : statsMgr.queryStatistics(
-                sid, OFStatisticsType.FLOW, ofMatch, 6000);
+                sid, OFStatisticsType.FLOW, ofMatch);
 
         /*
          * Convert and filter the statistics per container
@@ -149,7 +149,7 @@ public class ReadServiceFilter implements IPluginReadServiceFilter,
         long sid = (Long) node.getID();
         List<OFStatistics> ofList = (cached == true) ? statsMgr
                 .getOFFlowStatistics(sid) : statsMgr.queryStatistics(sid,
-                OFStatisticsType.FLOW, null, 6000);
+                OFStatisticsType.FLOW, null);
 
         /*
          * Convert and filter the statistics per container
@@ -174,7 +174,7 @@ public class ReadServiceFilter implements IPluginReadServiceFilter,
         long sid = (Long) node.getID();
         List<OFStatistics> ofList = (cached == true) ? statsMgr
                 .getOFDescStatistics(sid) : statsMgr.queryStatistics(sid,
-                OFStatisticsType.DESC, null, 6000);
+                OFStatisticsType.DESC, null);
 
         return new DescStatisticsConverter(ofList).getHwDescription();
     }
@@ -382,7 +382,7 @@ public class ReadServiceFilter implements IPluginReadServiceFilter,
         short portId = (Short) connector.getID();
         List<OFStatistics> ofList = (cached == true) ? statsMgr
                 .getOFPortStatistics(sid, portId) : statsMgr.queryStatistics(
-                sid, OFStatisticsType.PORT, portId, 6000);
+                sid, OFStatisticsType.PORT, portId);
 
         List<NodeConnectorStatistics> ncStatistics = new PortStatisticsConverter(
                 sid, ofList).getNodeConnectorStatsList();
@@ -397,7 +397,7 @@ public class ReadServiceFilter implements IPluginReadServiceFilter,
         long sid = (Long) node.getID();
         List<OFStatistics> ofList = (cached == true) ? statsMgr
                 .getOFPortStatistics(sid) : statsMgr.queryStatistics(sid,
-                OFStatisticsType.FLOW, null, 6000);
+                OFStatisticsType.FLOW, null);
 
         List<OFStatistics> filteredList = filterPortListPerContainer(
                 containerName, sid, ofList);
index b62b068..5d0ee5d 100644 (file)
@@ -226,7 +226,7 @@ public class TopologyServiceShim implements IDiscoveryService,
 
         for (NodeConnector connector : globalContainerEdges.keySet()) {
             // Skip if node connector belongs to production switch
-            if (connector.getType() == NodeConnector.NodeConnectorIDType.PRODUCTION) {
+            if (connector.getType().equals(NodeConnector.NodeConnectorIDType.PRODUCTION)) {
                 continue;
             }
 
@@ -326,7 +326,8 @@ public class TopologyServiceShim implements IDiscoveryService,
             return;
         }
         if ((this.topologyServiceShimListeners != null)
-                && !this.topologyServiceShimListeners.containsKey(s)) {
+                && !this.topologyServiceShimListeners
+                       .containsKey(containerName)) {
             this.topologyServiceShimListeners.put(containerName, s);
             logger.trace("Added topologyServiceShimListener for container:"
                     + containerName);
@@ -345,7 +346,11 @@ public class TopologyServiceShim implements IDiscoveryService,
             return;
         }
         if ((this.topologyServiceShimListeners != null)
-                && this.topologyServiceShimListeners.containsKey(s)) {
+                && this.topologyServiceShimListeners
+                .containsKey(containerName)
+                && this.topologyServiceShimListeners
+                .get(containerName).equals(s)
+                ) {
             this.topologyServiceShimListeners.remove(containerName);
             logger.trace("Removed topologyServiceShimListener for container: "
                     + containerName);
index 77e6d95..34cfd4b 100644 (file)
@@ -360,7 +360,6 @@ public class DijkstraImplementation implements IRouting, ITopologyManagerAware {
                 updateTopo(e, (short) bw.getValue(), add);
             }
             if (this.routingAware != null) {
-                log.info("Invoking routingAware listeners");
                 for (IListenRoutingUpdates ra : this.routingAware) {
                     try {
                         ra.recalculateDone();
index 8582046..6ff233b 100644 (file)
@@ -23,14 +23,14 @@ public enum ActionType {
     SW_PATH("software path", 0, 0), // OF Local
     HW_PATH("harware path", 0, 0), OUTPUT("output", 0, 0xffff), // physical port
     ENQUEUE("enqueue", 0, 0xffff), SET_DL_SRC("setDlSrc", 0, 0), SET_DL_DST(
-            "setDlDst", 0, 0), SET_VLAN_ID("setVlan", 2, 0xfff), SET_VLAN_PCP(
+            "setDlDst", 0, 0), SET_VLAN_ID("setVlan", 1, 0xfff), SET_VLAN_PCP(
             "setVlanPcp", 0, 0x7), SET_VLAN_CFI("setVlanCif", 0, 0x1), POP_VLAN(
             "stripVlan", 0, 0), // Pop
     PUSH_VLAN("pushVlan", 0, 0xffff), // Push (the max value only takes into account the TCI portion of the 802.1q header)
     SET_DL_TYPE("setDlType", 0, 0xffff), // Set ethertype/length field
     SET_NW_SRC("setNwSrc", 0, 0), SET_NW_DST("setNwDst", 0, 0), SET_NW_TOS(
-            "setNwTos", 0, 0xff), SET_TP_SRC("setTpSrc", 0, 0xffff), SET_TP_DST(
-            "setTpDst", 0, 0xffff), SET_NEXT_HOP("setNextHop", 0, 0);
+            "setNwTos", 0, 0xff), SET_TP_SRC("setTpSrc", 1, 0xffff), SET_TP_DST(
+            "setTpDst", 1, 0xffff), SET_NEXT_HOP("setNextHop", 0, 0);
 
     private String id;
     private int minValue;
diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Description.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Description.java
new file mode 100644 (file)
index 0000000..4233dcb
--- /dev/null
@@ -0,0 +1,54 @@
+package org.opendaylight.controller.sal.core;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+
+/**
+ * The class represents the Name property of an element.
+ */
+@XmlRootElement
+@SuppressWarnings("serial")
+public class Description extends Property {
+    @XmlElement
+    private String description;
+    public static final String propertyName = "description";
+
+    /*
+     * Private constructor used for JAXB mapping
+     */
+    private Description() {
+        super(propertyName);
+        this.description = null;
+    }
+
+    public Description(String description) {
+        super(propertyName);
+        this.description = description;
+    }
+
+    public Description clone() {
+        return new Description(this.description);
+    }
+
+    public String getValue() {
+        return this.description;
+    }
+
+    @Override
+    public int hashCode() {
+        return HashCodeBuilder.reflectionHashCode(this);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        return EqualsBuilder.reflectionEquals(this, obj);
+    }
+
+    @Override
+    public String toString() {
+        return "Description[" + description + "]";
+    }
+}
index 74617c7..bf67ed8 100644 (file)
@@ -18,8 +18,6 @@ import javax.xml.bind.annotation.XmlElement;
 
 /**
  * The class represents the Name property of an element.
- *
- *
  */
 @XmlRootElement
 @SuppressWarnings("serial")
index b199e5c..f54a515 100644 (file)
  */
 package org.opendaylight.controller.sal.core;
 
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.Set;
-import java.math.BigInteger;
-
 import java.io.Serializable;
-import java.lang.String;
+import java.math.BigInteger;
+import java.util.Set;
 import java.util.UUID;
-import java.lang.Long;
-import java.lang.Class;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.opendaylight.controller.sal.utils.HexEncode;
+import java.util.concurrent.ConcurrentHashMap;
 
-import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
 
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.opendaylight.controller.sal.utils.HexEncode;
+
 /**
  * Describe a generic network element in multiple SDNs technologies. A
  * Node is identified by the pair (NodeType, NodeID), the nodetype are
index bbe952d..96e6cc7 100644 (file)
  */
 package org.opendaylight.controller.sal.core;
 
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import java.util.concurrent.ConcurrentHashMap;
 import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
+import java.util.concurrent.ConcurrentHashMap;
 
-import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.tuple.ImmutablePair;
 
 /**
  * Describe a generic network element attachment points,
index 16c85a1..f39de8f 100644 (file)
@@ -9,6 +9,7 @@
 
 package org.opendaylight.controller.sal.flowprogrammer;
 
+import java.io.Serializable;
 import java.net.Inet6Address;
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -35,8 +36,9 @@ import org.opendaylight.controller.sal.utils.EtherTypes;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
-public class Flow implements Cloneable {
-    @XmlElement
+public class Flow implements Cloneable, Serializable {
+       private static final long serialVersionUID = 1L;
+       @XmlElement
     private Match match;
     @XmlElement
     private List<Action> actions;
index 7dbb593..41b91e1 100644 (file)
@@ -27,7 +27,7 @@ public interface IListenInventoryUpdates {
      * @param node                     {@link org.opendaylight.controller.sal.core.Node} being updated
      * @param type             {@link org.opendaylight.controller.sal.core.UpdateType}
      * @param props            set of {@link org.opendaylight.controller.sal.core.Property} such as
-     *                                                 {@link org.opendaylight.controller.sal.core.Name} and/or
+     *                                                 {@link org.opendaylight.controller.sal.core.Description} and/or
      *                                                 {@link org.opendaylight.controller.sal.core.Tier} etc.
      */
     public void updateNode(Node node, UpdateType type, Set<Property> props);
@@ -38,7 +38,7 @@ public interface IListenInventoryUpdates {
      * @param nodeConnector    {@link org.opendaylight.controller.sal.core.NodeConnector} being updated
      * @param type             {@link org.opendaylight.controller.sal.core.UpdateType}
      * @param props            set of {@link org.opendaylight.controller.sal.core.Property} such as
-     *                                                 {@link org.opendaylight.controller.sal.core.Name} and/or
+     *                                                 {@link org.opendaylight.controller.sal.core.Description} and/or
      *                                                 {@link org.opendaylight.controller.sal.core.State} etc.
      */
     public void updateNodeConnector(NodeConnector nodeConnector,
index 6fb9283..124c34a 100644 (file)
@@ -27,7 +27,7 @@ public interface IPluginOutInventoryService {
      * @param node                     {@link org.opendaylight.controller.sal.core.Node} being updated
      * @param type             {@link org.opendaylight.controller.sal.core.UpdateType}
      * @param props            set of {@link org.opendaylight.controller.sal.core.Property} such as
-     *                                                 {@link org.opendaylight.controller.sal.core.Name} and/or
+     *                                                 {@link org.opendaylight.controller.sal.core.Description} and/or
      *                                                 {@link org.opendaylight.controller.sal.core.Tier} etc.
      */
     public void updateNode(Node node, UpdateType type, Set<Property> props);
@@ -38,7 +38,7 @@ public interface IPluginOutInventoryService {
      * @param nodeConnector    {@link org.opendaylight.controller.sal.core.NodeConnector} being updated
      * @param type             {@link org.opendaylight.controller.sal.core.UpdateType}
      * @param props            set of {@link org.opendaylight.controller.sal.core.Property} such as
-     *                                                 {@link org.opendaylight.controller.sal.core.Name} and/or
+     *                                                 {@link org.opendaylight.controller.sal.core.Description} and/or
      *                                                 {@link org.opendaylight.controller.sal.core.State} etc.
      */
     public void updateNodeConnector(NodeConnector nodeConnector,
index e376ba7..736314c 100644 (file)
@@ -9,12 +9,12 @@
 
 package org.opendaylight.controller.sal.match;
 
+import java.io.Serializable;
 import java.net.Inet4Address;
 import java.net.Inet6Address;
 import java.net.InetAddress;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -39,8 +39,9 @@ import org.opendaylight.controller.sal.utils.NetUtils;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
-public class Match implements Cloneable {
-    private static final Map<MatchType, MatchType> reversableMatches;
+public class Match implements Cloneable, Serializable {
+       private static final long serialVersionUID = 1L;
+       private static final Map<MatchType, MatchType> reversableMatches;
     static {
         Map<MatchType, MatchType> map = new HashMap<MatchType, MatchType>();
         map.put(MatchType.DL_SRC, MatchType.DL_DST);
index 08d4fa6..12e7728 100644 (file)
@@ -9,6 +9,8 @@
 
 package org.opendaylight.controller.sal.match;
 
+import java.io.Serializable;
+
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
@@ -16,7 +18,6 @@ import javax.xml.bind.annotation.XmlRootElement;
 
 import org.apache.commons.lang3.builder.EqualsBuilder;
 import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.opendaylight.controller.sal.utils.HexEncode;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -28,8 +29,9 @@ import org.slf4j.LoggerFactory;
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
 
-public class MatchField implements Cloneable {
-    private static final Logger logger = LoggerFactory
+public class MatchField implements Cloneable, Serializable {
+       private static final long serialVersionUID = 1L;
+       private static final Logger logger = LoggerFactory
             .getLogger(MatchField.class);
        private MatchType type; // the field we want to match
     private Object value; // the value of the field we want to match
index 8379f07..96ddbf4 100644 (file)
@@ -25,9 +25,9 @@ public enum MatchType {
     IN_PORT("inPort", 1 << 0, NodeConnector.class, 1, 0), 
     DL_SRC("dlSrc", 1 << 1, Byte[].class, 0, 0xffffffffffffL), 
     DL_DST("dlDst", 1 << 2, Byte[].class, 0, 0xffffffffffffL), 
-    DL_VLAN("dlVlan", 1 << 3, Short.class, 2, 0xfff), // 2 bytes
+    DL_VLAN("dlVlan", 1 << 3, Short.class, 1, 0xfff), // 2 bytes
     DL_VLAN_PR("dlVlanPriority", 1 << 4, Byte.class, 0, 0x7), // 3 bits
-    DL_OUTER_VLAN("dlOuterVlan", 1 << 5, Short.class, 2, 0xfff), 
+    DL_OUTER_VLAN("dlOuterVlan", 1 << 5, Short.class, 1, 0xfff), 
     DL_OUTER_VLAN_PR("dlOuterVlanPriority", 1 << 6, Short.class, 0, 0x7), 
     DL_TYPE("dlType", 1 << 7, Short.class, 0, 0xffff), // 2 bytes
     NW_TOS("nwTOS", 1 << 8, Byte.class, 0, 0xff), // 1 byte
@@ -216,6 +216,8 @@ public enum MatchType {
                                return ((Integer) (((Short)value).intValue() & 0x7FFF | 0x8000)).toString();
                        }
                        break;
+               default:
+                       break;
                }
                return value.toString();
        }
index b683267..65efd3c 100644 (file)
@@ -9,20 +9,16 @@
 
 package org.opendaylight.controller.sal.reader;
 
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
 
 /**
- * Represents the switch description information
- *
- *
- *
+ * Represents the network node description information
  */
 public class NodeDescription {
     private String manufacturer;
     private String hardware;
     private String software;
     private String serialNumber;
-    private String sdnProtocolDescription;
+    private String description;
 
     public NodeDescription() {
 
@@ -60,17 +56,18 @@ public class NodeDescription {
         this.serialNumber = serialNumber;
     }
 
-    public String getSdnProtocolDescription() {
-        return sdnProtocolDescription;
+    public String getDescription() {
+        return description;
     }
 
-    public void setSdnProtocolDescription(String sdnProtocolDescription) {
-        this.sdnProtocolDescription = sdnProtocolDescription;
+    public void setDescription(String description) {
+        this.description = description;
     }
 
     @Override
     public String toString() {
-        return "HwDescription[" + ReflectionToStringBuilder.toString(this)
-                + "]";
+        return "HwDescription[manufacturer=" + manufacturer + ", hardware="
+                       + hardware + ", software=" + software + ", serialNumber=" 
+                       + serialNumber + ", description=" + description + "]";
     }
 }
index cf0f022..eeddc0b 100644 (file)
@@ -66,7 +66,7 @@ public class ActionTest {
         Assert.assertFalse(action.isValid());
 
         action = new SetVlanId(1);
-        Assert.assertFalse(action.isValid());
+        Assert.assertTrue(action.isValid());
 
         action = new SetVlanId(4096);
         Assert.assertFalse(action.isValid());
@@ -184,7 +184,7 @@ public class ActionTest {
         Assert.assertTrue(action.isValid());
 
         action = new SetTpDst(0);
-        Assert.assertTrue(action.isValid());
+        Assert.assertFalse(action.isValid());
 
         action = new SetTpSrc(-1);
         Assert.assertFalse(action.isValid());
index a78182f..a720bdf 100644 (file)
@@ -20,19 +20,19 @@ public class NodeDescriptionTest {
                NodeDescription ncDesc = new NodeDescription();
                ncDesc.setHardware("Hardware1");
                ncDesc.setManufacturer("Manufacturer1");
-               ncDesc.setSdnProtocolDescription("SDNProtocol1");
+               ncDesc.setDescription("SDNProtocol1");
                ncDesc.setSerialNumber("serialNumber1");
                ncDesc.setSoftware("Software1");
                
                Assert.assertTrue(ncDesc.getHardware().equals("Hardware1"));
                Assert.assertTrue(ncDesc.getManufacturer().equals("Manufacturer1"));
-               Assert.assertTrue(ncDesc.getSdnProtocolDescription().equals("SDNProtocol1"));
+               Assert.assertTrue(ncDesc.getDescription().equals("SDNProtocol1"));
                Assert.assertTrue(ncDesc.getSerialNumber().equals("serialNumber1"));
                Assert.assertTrue(ncDesc.getSoftware().equals("Software1"));
                
                Assert.assertFalse(ncDesc.getHardware().equals("Hardware2"));
                Assert.assertFalse(ncDesc.getManufacturer().equals("Manufacturer2"));
-               Assert.assertFalse(ncDesc.getSdnProtocolDescription().equals("SDNProtocol2"));
+               Assert.assertFalse(ncDesc.getDescription().equals("SDNProtocol2"));
                Assert.assertFalse(ncDesc.getSerialNumber().equals("serialNumber2"));
                Assert.assertFalse(ncDesc.getSoftware().equals("Software2"));
 
index 73e3376..e7b8c59 100644 (file)
@@ -26,7 +26,7 @@ public interface IInventoryListener {
      * @param node                     {@link org.opendaylight.controller.sal.core.Node} being updated
      * @param type             {@link org.opendaylight.controller.sal.core.UpdateType}
      * @param propMap          map of {@link org.opendaylight.controller.sal.core.Property} such as
-     *                                                 {@link org.opendaylight.controller.sal.core.Name} and/or
+     *                                                 {@link org.opendaylight.controller.sal.core.Description} and/or
      *                                                 {@link org.opendaylight.controller.sal.core.Tier} etc.
      */
     public void notifyNode(Node node, UpdateType type,
@@ -38,7 +38,7 @@ public interface IInventoryListener {
      * @param nodeConnector    {@link org.opendaylight.controller.sal.core.NodeConnector} being updated
      * @param type             {@link org.opendaylight.controller.sal.core.UpdateType}
      * @param propMap          map of {@link org.opendaylight.controller.sal.core.Property} such as
-     *                                                 {@link org.opendaylight.controller.sal.core.Name} and/or
+     *                                                 {@link org.opendaylight.controller.sal.core.Description} and/or
      *                                                 {@link org.opendaylight.controller.sal.core.State} etc.
      */
     public void notifyNodeConnector(NodeConnector nodeConnector,
index 15aeda3..ddc5f8f 100755 (executable)
@@ -170,7 +170,7 @@ public interface ISwitchManager {
      *
      * @param node {@link org.opendaylight.controller.sal.core.Node}
      * @return map of {@link org.opendaylight.controller.sal.core.Property} such as
-     *            {@link org.opendaylight.controller.sal.core.Name} and/or
+     *            {@link org.opendaylight.controller.sal.core.Description} and/or
      *                    {@link org.opendaylight.controller.sal.core.Tier} etc.
      */
     public Map<String, Property> getNodeProps(Node node);
@@ -238,7 +238,7 @@ public interface ISwitchManager {
      *
      * @param nodeConnector {@link org.opendaylight.controller.sal.core.NodeConnector}
      * @return map of {@link org.opendaylight.controller.sal.core.Property} such as
-     *                    {@link org.opendaylight.controller.sal.core.Name} and/or
+     *                    {@link org.opendaylight.controller.sal.core.Description} and/or
      *                    {@link org.opendaylight.controller.sal.core.State} etc.
      */
     public Map<String, Property> getNodeConnectorProps(
@@ -307,17 +307,6 @@ public interface ISwitchManager {
      */
     public Boolean isNodeConnectorEnabled(NodeConnector nodeConnector);
 
-    /**
-     * Return the list of mapping "nodeId"/"nodeName" for each connected node. 
-     * Each map contains two string keys: "nodeId", "nodeName". 
-     * Value associated to "nodeId" is the node id in string hex format. 
-     * Value associated to "nodeName" is the name of the node. If no name was set, 
-     * it will be the node id in string hex format.
-     *
-     * @return list of map
-     */
-    public List<Map<String, String>> getListNodeIdNameMap();
-
     /**
      * Return controller MAC address
         *
@@ -358,4 +347,15 @@ public interface ISwitchManager {
         * @return {@link org.opendaylight.controller.sal.core.Property}
         */
     public Property createProperty(String propName, String propValue);
+    
+    /**
+     * Returns the description for the specified node. It is either the one 
+     * configured by user or the description advertised by the node.
+     * 
+     * @param node the network node identifier
+     * @return the description of the specified node. If no description is 
+     * configured and the network node does not provide its description,
+     * an empty string is returned.
+     */
+    public String getNodeDescription(Node node);
 }
index 3624dd7..87dd99d 100644 (file)
 package org.opendaylight.controller.switchmanager;
 
 import java.io.Serializable;
-import java.lang.reflect.Field;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-import javax.xml.bind.annotation.XmlRootElement;
+
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.utils.GUIField;
index 758a99b..ffb8ec0 100644 (file)
@@ -21,14 +21,14 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
 public class SwitchConfig implements Serializable {
     private static final long serialVersionUID = 1L;
     String nodeId;
-    String nodeName;
+    String description;
     String tier;
     String mode;
 
-    public SwitchConfig(String nodeId, String nodeName, String tier, String mode) {
+    public SwitchConfig(String nodeId, String description, String tier, String mode) {
         super();
         this.nodeId = nodeId;
-        this.nodeName = nodeName;
+        this.description = description;
         this.tier = tier;
         this.mode = mode;
     }
@@ -37,8 +37,8 @@ public class SwitchConfig implements Serializable {
         return nodeId;
     }
 
-    public String getNodeName() {
-        return nodeName;
+    public String getNodeDescription() {
+        return description;
     }
 
     public String getTier() {
index d818004..54508de 100755 (executable)
@@ -41,6 +41,7 @@ import org.opendaylight.controller.clustering.services.IClusterServices;
 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
 import org.opendaylight.controller.sal.core.Bandwidth;
 import org.opendaylight.controller.sal.core.Config;
+import org.opendaylight.controller.sal.core.Description;
 import org.opendaylight.controller.sal.core.Name;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
@@ -601,8 +602,8 @@ public class SwitchManagerImpl implements ISwitchManager,
                 } else {
                     propMap = new HashMap<String, Property>();
                 }
-                Property name = new Name(cfgObject.getNodeName());
-                propMap.put(name.getName(), name);
+                Property desc = new Description(cfgObject.getNodeDescription());
+                propMap.put(desc.getName(), desc);
                 Property tier = new Tier(Integer.parseInt(cfgObject.getTier()));
                 propMap.put(tier.getName(), tier);
                 addNodeProps(node, propMap);
@@ -738,8 +739,8 @@ public class SwitchManagerImpl implements ISwitchManager,
             String nodeId = node.getNodeIDString();
             for (SwitchConfig conf : nodeConfigList.values()) {
                 if (conf.getNodeId().equals(nodeId)) {
-                    Property name = new Name(conf.getNodeName());
-                    propMap.put(name.getName(), name);
+                    Property description = new Description(conf.getNodeDescription());
+                    propMap.put(description.getName(), description);
                     Property tier = new Tier(Integer.parseInt(conf.getTier()));
                     propMap.put(tier.getName(), tier);
                     proactiveForwarding = conf.isProactive();
@@ -1034,24 +1035,6 @@ public class SwitchManagerImpl implements ISwitchManager,
         return (propMap != null) ? propMap.get(propName) : null;
     }
 
-    @Override
-    public List<Map<String, String>> getListNodeIdNameMap() {
-        List<Map<String, String>> list = new ArrayList<Map<String, String>>();
-        Set<Node> nset = this.nodeProps.keySet();
-        if (nset == null) {
-            return list;
-        }
-        for (Node node : nset) {
-            Map<String, String> map = new HashMap<String, String>(2);
-            Name nodeName = (Name) getNodeProp(node, Name.NamePropName);
-            map.put("nodeId", node.toString());
-            map.put("nodeName", ((nodeName == null) || nodeName.getValue()
-                    .equals("")) ? node.toString() : nodeName.getValue());
-            list.add(map);
-        }
-        return list;
-    }
-
     private byte[] getHardwareMAC() {
         Enumeration<NetworkInterface> nis;
         try {
@@ -1470,9 +1453,9 @@ public class SwitchManagerImpl implements ISwitchManager,
             return;
         }
         for (Node node : nodeSet) {
-            Name name = ((Name) getNodeProp(node, Name.NamePropName));
+               Description desc = ((Description) getNodeProp(node, Description.propertyName));
             Tier tier = ((Tier) getNodeProp(node, Tier.TierPropName));
-            String nodeName = (name == null) ? "" : name.getValue();
+            String nodeName = (desc == null) ? "" : desc.getValue();
             int tierNum = (tier == null) ? 0 : tier.getValue();
             ci.println(node + "            " + node.getType()
                     + "            " + nodeName + "            " + tierNum);
@@ -1762,8 +1745,8 @@ public class SwitchManagerImpl implements ISwitchManager,
                }
                
                try {
-                       if (propName.equalsIgnoreCase(Name.NamePropName)) {
-                               return new Name(propValue);
+                       if (propName.equalsIgnoreCase(Description.propertyName)) {
+                               return new Description(propValue);
                        } else if (propName.equalsIgnoreCase(Tier.TierPropName)) {
                                int tier = Integer.parseInt(propValue);
                                return new Tier(tier);
@@ -1779,4 +1762,21 @@ public class SwitchManagerImpl implements ISwitchManager,
 
                return null;
     }
+       
+       @Override
+       public String getNodeDescription(Node node) {
+       // Check first if user configured a name
+        SwitchConfig config = getSwitchConfig(node.getNodeIDString());
+        if (config != null) {
+               String configuredDesc = config.getNodeDescription();
+               if (configuredDesc != null && !configuredDesc.isEmpty()) {
+                       return configuredDesc;
+               }
+        }
+        
+        // No name configured by user, get the node advertised name
+        Description desc = (Description) getNodeProp(node, Description.propertyName);
+        return (desc == null /*|| desc.getValue().equalsIgnoreCase("none")*/) ?        
+                                       "" : desc.getValue();
+    }
 }
index 6b0a258..1499f9e 100644 (file)
@@ -129,7 +129,7 @@ public class SwitchTest {
         Assert.assertNull(sc.getMode());
         Assert.assertNull(sc.getNodeId());
         Assert.assertNull(sc.getTier());
-        Assert.assertNull(sc.getNodeName());
+        Assert.assertNull(sc.getNodeDescription());
         
         SwitchConfig sc3 = new SwitchConfig("123", "name", "tier", "mode");
         SwitchConfig sc4 = new SwitchConfig("123", "name", "tier", "mode");
@@ -137,7 +137,7 @@ public class SwitchTest {
         Assert.assertTrue(sc3.equals(sc4));
         
         Assert.assertTrue(sc3.getNodeId().equals("123"));
-        Assert.assertTrue(sc3.getNodeName().equals("name"));
+        Assert.assertTrue(sc3.getNodeDescription().equals("name"));
         Assert.assertTrue(sc3.getTier().equals("tier"));
         Assert.assertTrue(sc3.getMode().equals("mode"));
     }
index 77b3e13..5be771a 100644 (file)
@@ -89,12 +89,11 @@ public class Devices implements IOneWeb {
         for (Switch device : switchManager.getNetworkDevices()) {
             HashMap<String, String> nodeDatum = new HashMap<String, String>();
             Node node = device.getNode();
-            SwitchConfig switchConfig = switchManager.getSwitchConfig(node.getNodeIDString());
             Tier tier = (Tier) switchManager.getNodeProp(node,
                     Tier.TierPropName);
-            String swName = switchConfig == null ? null : switchConfig.getNodeName();
+
             nodeDatum.put("containerName", containerName);
-            nodeDatum.put("nodeName", swName);
+            nodeDatum.put("nodeName", switchManager.getNodeDescription(node));
             nodeDatum.put("nodeId", node.getNodeIDString());
             int tierNumber = (tier == null) ? TierHelper.unknownTierNumber
                     : tier.getValue();
@@ -442,7 +441,7 @@ public class Devices implements IOneWeb {
                     config.put(name, config_data.get(name));
                     // Add switch name value (non-configuration field)
                     config.put("nodeName",
-                            getNodeName(config_data.get("nodeId")));
+                            getNodeDesc(config_data.get("nodeId")));
                 }
                 config.put("json", config_json);
                 spanConfigs.add(config);
@@ -551,22 +550,19 @@ public class Devices implements IOneWeb {
         return resultBean;
     }
 
-    private String getNodeName(String nodeId) {
-        String nodeName = nodeId;
+    private String getNodeDesc(String nodeId) {
         ISwitchManager switchManager = (ISwitchManager) ServiceHelper
                 .getInstance(ISwitchManager.class, containerName, this);
-
-        Node node = Node.fromString(nodeId);
+        String description = "";
         if (switchManager != null) {
-            SwitchConfig config = switchManager.getSwitchConfig(node
-                    .getNodeIDString());
-            if (config != null) {
-                nodeName = config.getNodeName();
-            }
+               description = switchManager
+                               .getNodeDescription(Node.fromString(nodeId));
         }
-        return nodeName;
+        return (description.isEmpty() || description.equalsIgnoreCase("none"))?
+                       nodeId : description;
     }
 
+    
     /**
      * Is the operation permitted for the given level
      * 
index 7747022..d75d14c 100644 (file)
@@ -21,6 +21,7 @@ import org.opendaylight.controller.sal.authorization.UserLevel;
 import org.opendaylight.controller.sal.core.Name;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.utils.GlobalConstants;
 import org.opendaylight.controller.sal.utils.ServiceHelper;
 import org.opendaylight.controller.sal.utils.Status;
 import org.opendaylight.controller.sal.utils.StatusCode;
@@ -46,6 +47,7 @@ public class Flows implements IOneWeb {
     private static final String WEB_NAME = "Flows";
     private static final String WEB_ID = "flows";
     private static final short WEB_ORDER = 2;
+    private final String containerName = GlobalConstants.DEFAULT.toString();
 
     public Flows() {
         ServiceHelper.registerGlobalService(IOneWeb.class, this, null);
@@ -76,12 +78,12 @@ public class Flows implements IOneWeb {
     public Set<Map<String, Object>> getFlows() {
         // fetch frm
         IForwardingRulesManager frm = (IForwardingRulesManager) ServiceHelper
-                .getInstance(IForwardingRulesManager.class, "default", this);
+                .getInstance(IForwardingRulesManager.class, containerName, this);
         if (frm == null) { return null; }
 
         // fetch sm
         ISwitchManager switchManager = (ISwitchManager) ServiceHelper
-                .getInstance(ISwitchManager.class, "default", this);
+                .getInstance(ISwitchManager.class, containerName, this);
         if (switchManager == null) { return null; }
         
         // get static flow list
@@ -91,12 +93,12 @@ public class Flows implements IOneWeb {
                Map<String, Object> entry = new HashMap<String, Object>();
                entry.put("flow", flowConfig);
                entry.put("name", flowConfig.getName());
-               
-               Node node = flowConfig.getNode(); 
-               SwitchConfig switchConfig = switchManager.getSwitchConfig(node.getNodeIDString());
-               String nodeName = node.toString();
-               if (switchConfig != null) { nodeName = switchConfig.getNodeName(); }
-               entry.put("node", nodeName);
+               Node node = flowConfig.getNode();
+               String description = switchManager.getNodeDescription(node);
+               entry.put("node", 
+                               (description.isEmpty() || 
+                                               description.equalsIgnoreCase("none"))? 
+                                                               node.toString() : description);
                entry.put("nodeId", node.toString());
                output.add(entry);
         }
@@ -108,7 +110,7 @@ public class Flows implements IOneWeb {
     @ResponseBody
     public Map<String, Object> getNodePorts() {
         ISwitchManager switchManager = (ISwitchManager) ServiceHelper
-                .getInstance(ISwitchManager.class, "default", this);
+                .getInstance(ISwitchManager.class, containerName, this);
         if (switchManager == null) { return null; }
 
         Map<String, Object> nodes = new HashMap<String, Object>();
@@ -134,12 +136,11 @@ public class Flows implements IOneWeb {
             entry.put("ports", port);
             
             // add name
-            String nodeName = node.getNode().toString();
-            SwitchConfig config = switchManager.getSwitchConfig(node.getNode().getNodeIDString());
-            if (config != null) {
-               nodeName = config.getNodeName();
-            }
-            entry.put("name", nodeName);
+            String description = switchManager
+                       .getNodeDescription(node.getNode());
+            entry.put("name", (description.isEmpty() || 
+                       description.equalsIgnoreCase("none"))? 
+                       node.getNode().toString() : description);
             
             // add to the node
             nodes.put(node.getNode().toString(), entry);
@@ -152,7 +153,7 @@ public class Flows implements IOneWeb {
     @ResponseBody
     public Map<String, Object> getNodeFlows() {
         ISwitchManager switchManager = (ISwitchManager) ServiceHelper
-                .getInstance(ISwitchManager.class, "default", this);
+                .getInstance(ISwitchManager.class, containerName, this);
         if (switchManager == null) { return null; }
         IForwardingRulesManager frm = (IForwardingRulesManager) ServiceHelper
                 .getInstance(IForwardingRulesManager.class, "default", this);
@@ -165,13 +166,13 @@ public class Flows implements IOneWeb {
             
             List<FlowConfig> flows = frm.getStaticFlows(node);
             
-            String nodeName = node.toString();
+            String nodeDesc = node.toString();
             SwitchConfig config = switchManager.getSwitchConfig(node.getNodeIDString());
             if (config != null) {
-               nodeName = config.getNodeName();
+               nodeDesc = config.getNodeDescription();
             }
             
-            nodes.put(nodeName, flows.size());
+            nodes.put(nodeDesc, flows.size());
         }
 
         return nodes;
@@ -186,7 +187,7 @@ public class Flows implements IOneWeb {
        }
        
         IForwardingRulesManager frm = (IForwardingRulesManager) ServiceHelper
-                .getInstance(IForwardingRulesManager.class, "default", this);
+                .getInstance(IForwardingRulesManager.class, containerName, this);
         if (frm == null) { return null; }
 
         Gson gson = new Gson();
@@ -208,7 +209,7 @@ public class Flows implements IOneWeb {
        if (!isUserAuthorized(UserLevel.NETWORKADMIN)) { return "Operation not authorized"; }
        
        IForwardingRulesManager frm = (IForwardingRulesManager) ServiceHelper
-                .getInstance(IForwardingRulesManager.class, "default", this);
+                .getInstance(IForwardingRulesManager.class, containerName, this);
         if (frm == null) { return null; }
         
         Status result = null;
index aeffad2..3366912 100644 (file)
@@ -151,7 +151,7 @@ public class Topology {
                Map<String, Object> nodeEntry = cache.get(node.id());
                if (config != null) {
                        Map<String, String> data = (Map<String, String>) nodeEntry.get("data");
-                       data.put("$desc", config.getNodeName());
+                       data.put("$desc", config.getNodeDescription());
                        nodeEntry.put("data", data);
                }
                stage.put(node.id(), nodeEntry);
@@ -164,7 +164,7 @@ public class Topology {
     protected NodeBean createNodeBean(SwitchConfig config, Node node) {
        NodeBean bean = null;
        if (config != null) {
-               bean = new NodeBean(node.toString(), config.getNodeName(), NodeType.NODE);
+               bean = new NodeBean(node.toString(), config.getNodeDescription(), NodeType.NODE);
        } else {
                bean = new NodeBean(node.toString(), node.toString(), NodeType.NODE);
        }
@@ -183,7 +183,7 @@ public class Topology {
                        Map<String, Object> nodeEntry = cache.get(node.id());
                        if (config != null) {
                                Map<String, String> data = (Map<String, String>) nodeEntry.get("data");
-                       data.put("$desc", config.getNodeName());
+                       data.put("$desc", config.getNodeDescription());
                        nodeEntry.put("data", data);
                        }
                stage.put(node.id(), nodeEntry);
index e20c35a..c2d9614 100644 (file)
@@ -35,7 +35,6 @@ import org.opendaylight.controller.sal.utils.IPProtocols;
 import org.opendaylight.controller.sal.utils.ServiceHelper;
 import org.opendaylight.controller.statisticsmanager.IStatisticsManager;
 import org.opendaylight.controller.switchmanager.ISwitchManager;
-import org.opendaylight.controller.switchmanager.SwitchConfig;
 import org.opendaylight.controller.web.IOneWeb;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -85,15 +84,11 @@ public class Troubleshoot implements IOneWeb {
         Set<Node> nodeSet = null;
         if (switchManager != null) {
             nodeSet = switchManager.getNodes();
-        } else {
-            // TODO: Change to use logger instead.
-            System.out.println("SwitchManager reference is NULL");
         }
         if (nodeSet != null) {
             for (Node node : nodeSet) {
                 HashMap<String, String> device = new HashMap<String, String>();
-                SwitchConfig switchConfig = switchManager.getSwitchConfig(node.getNodeIDString());
-                device.put("nodeName", switchConfig == null ? "" : switchConfig.getNodeName());
+                device.put("nodeName", switchManager.getNodeDescription(node));
                 device.put("nodeId", node.toString());
                 lines.add(device);
             }
@@ -101,7 +96,7 @@ public class Troubleshoot implements IOneWeb {
         TroubleshootingJsonBean result = new TroubleshootingJsonBean();
 
         List<String> guiFieldNames = new ArrayList<String>();
-        guiFieldNames.add("Node Names");
+        guiFieldNames.add("Node");
         guiFieldNames.add("Node ID");
         guiFieldNames.add("Statistics");
 
@@ -119,15 +114,11 @@ public class Troubleshoot implements IOneWeb {
         Set<Node> nodeSet = null;
         if (switchManager != null) {
             nodeSet = switchManager.getNodes();
-        } else {
-            // TODO: Change to use logger instead.
-            System.out.println("SwitchManager reference is NULL");
         }
         if (nodeSet != null) {
             for (Node node : nodeSet) {
                 HashMap<String, String> device = new HashMap<String, String>();
-                SwitchConfig switchConfig = switchManager.getSwitchConfig(node.getNodeIDString());
-                device.put("nodeName", switchConfig == null ? "" : switchConfig.getNodeName());
+                device.put("nodeName", switchManager.getNodeDescription(node));
                 device.put("nodeId", node.toString());
                 TimeStamp timeStamp = (TimeStamp) switchManager.getNodeProp(
                         node, TimeStamp.TimeStampPropName);
@@ -140,7 +131,7 @@ public class Troubleshoot implements IOneWeb {
         TroubleshootingJsonBean result = new TroubleshootingJsonBean();
 
         List<String> guiFieldNames = new ArrayList<String>();
-        guiFieldNames.add("Node Names");
+        guiFieldNames.add("Node");
         guiFieldNames.add("Node ID");
         guiFieldNames.add("Connected");
 
@@ -228,7 +219,13 @@ public class Troubleshoot implements IOneWeb {
         HashMap<String, String> row = new HashMap<String, String>();
         Flow flow = flowOnNode.getFlow();
         Match match = flow.getMatch();
-        row.put("nodeName", getNodeName(node));
+        ISwitchManager switchManager = (ISwitchManager) ServiceHelper
+                .getInstance(ISwitchManager.class, containerName, this);
+        String desc = (switchManager == null)? 
+                       "" : switchManager.getNodeDescription(node);
+        desc = (desc.isEmpty() || desc.equalsIgnoreCase("none"))? 
+                       node.toString(): desc;
+        row.put("nodeName", desc);
         if (match.isPresent(MatchType.IN_PORT)) {
             row.put(MatchType.IN_PORT.id(), ((NodeConnector) flow.getMatch()
                     .getField(MatchType.IN_PORT).getValue()).getID().toString());
@@ -350,17 +347,4 @@ public class Troubleshoot implements IOneWeb {
         return row;
     }
 
-    private String getNodeName(Node node) {
-        String nodeName = "";
-        ISwitchManager switchManager = (ISwitchManager) ServiceHelper
-                .getInstance(ISwitchManager.class, containerName, this);
-        if (switchManager != null) {
-            SwitchConfig config = switchManager.getSwitchConfig(node
-                    .getNodeIDString());
-            if (config != null) {
-                nodeName = config.getNodeName();
-            }
-        }
-        return nodeName;
-    }
 }