import org.opendaylight.controller.protocol_plugin.openflow.IInventoryShimInternalListener;
import org.opendaylight.controller.protocol_plugin.openflow.core.IController;
import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitch;
-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.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.Tables;
-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;
private ConcurrentMap<Node, Map<String, Property>> nodeProps; // properties are maintained in global container only
private ConcurrentMap<NodeConnector, Map<String, Property>> nodeConnectorProps; // properties are maintained in global container only
private boolean isDefaultContainer = false;
+ private String containerName = null;
void setController(IController s) {
this.controller = s;
Dictionary props = c.getServiceProperties();
if (props != null) {
- String containerName = (String) props.get("containerName");
+ containerName = (String) props.get("containerName");
isDefaultContainer = containerName.equals(GlobalConstants.DEFAULT
.toString());
}
*/
@Override
public ConcurrentMap<Node, Map<String, Property>> getNodeProps() {
- if (nodeProps == null)
- return null;
- Map<Long, ISwitch> switches = controller.getSwitches();
- for (Map.Entry<Long, ISwitch> entry : switches.entrySet()) {
- ISwitch sw = entry.getValue();
- Node node = OFSwitchToNode(sw);
- Map<String, Property> propMap = null;
- if (isDefaultContainer) {
- propMap = new HashMap<String, Property>();
- byte tables = sw.getTables();
- Tables t = new Tables(tables);
- if (t != null) {
- propMap.put(Tables.TablesPropName, t);
- }
- int cap = sw.getCapabilities();
- Capabilities c = new Capabilities(cap);
- if (c != null) {
- propMap.put(Capabilities.CapabilitiesPropName, c);
- }
- int act = sw.getActions();
- Actions a = new Actions(act);
- if (a != null) {
- propMap.put(Actions.ActionsPropName, a);
- }
- int buffers = sw.getBuffers();
- Buffers b = new Buffers(buffers);
- if (b != null) {
- propMap.put(Buffers.BuffersPropName, b);
- }
- Date connectedSince = sw.getConnectedDate();
- Long connectedSinceTime = (connectedSince == null) ? 0
- : connectedSince.getTime();
- TimeStamp timeStamp = new TimeStamp(connectedSinceTime,
- "connectedSince");
- propMap.put(TimeStamp.TimeStampPropName, timeStamp);
- nodeProps.put(node, propMap);
- }
- }
+ logger.debug("getNodePros for container {}", containerName);
return nodeProps;
}
}
private void addNode(Node node, Set<Property> props) {
- logger.trace("{} added, props: {}", node, props);
if (nodeProps == null) {
return;
}
+ Set<Node> nodeSet = nodeProps.keySet();
+ if (((props == null) || props.isEmpty()) && (nodeSet != null)
+ && nodeSet.contains(node)) {
+ // node already added
+ return;
+ }
+
+ logger.trace("addNode: {} added, props: {} for container {}",
+ new Object[] { node, props, containerName });
+
// update local cache
- Map<String, Property> propMap = new HashMap<String, Property>();
- for (Property prop : props) {
- propMap.put(prop.getName(), prop);
+ Map<String, Property> propMap = nodeProps.get(node);
+ if (propMap == null) {
+ propMap = new HashMap<String, Property>();
+ }
+
+ if (props != null) {
+ for (Property prop : props) {
+ propMap.put(prop.getName(), prop);
+ }
}
nodeProps.put(node, propMap);