package org.opendaylight.controller.sal.core;
+import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
@XmlRootElement
public class Latency extends Property {
private static final long serialVersionUID = 1L;
- private long latency;
+
+ @XmlElement
+ private long latencyValue;
public static final long LATENCYUNK = 0;
public static final long LATENCY1ns = (long) Math.pow(10, 3);
*/
private Latency() {
super(LatencyPropName);
- this.latency = LATENCYUNK;
+ this.latencyValue = LATENCYUNK;
}
public Latency(long latency) {
super(LatencyPropName);
- this.latency = latency;
+ this.latencyValue = latency;
}
public Latency(int latency) {
super(LatencyPropName);
- this.latency = (long) latency;
+ this.latencyValue = (long) latency;
}
public Latency(short latency) {
super(LatencyPropName);
- this.latency = (long) latency;
+ this.latencyValue = (long) latency;
}
public Latency clone() {
- return new Latency(this.latency);
+ return new Latency(this.latencyValue);
}
public long getValue() {
- return this.latency;
+ return this.latencyValue;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
- result = prime * result + (int) (latency ^ (latency >>> 32));
+ result = prime * result + (int) (latencyValue ^ (latencyValue >>> 32));
return result;
}
if (getClass() != obj.getClass())
return false;
Latency other = (Latency) obj;
- if (latency != other.latency)
+ if (latencyValue != other.latencyValue)
return false;
return true;
}
StringBuffer sb = new StringBuffer();
sb.append("Latency[");
- if (this.latency == 0) {
+ if (this.latencyValue == 0) {
sb.append("UnKnown");
- } else if (this.latency < LATENCY1ns) {
- sb.append(this.latency + "psec");
- } else if (this.latency < LATENCY1us) {
- sb.append(Long.toString(this.latency / LATENCY1ns) + "nsec");
- } else if (this.latency < LATENCY1ms) {
- sb.append(Long.toString(this.latency / LATENCY1us) + "usec");
- } else if (this.latency < LATENCY1s) {
- sb.append(Long.toString(this.latency / LATENCY1ms) + "msec");
+ } else if (this.latencyValue < LATENCY1ns) {
+ sb.append(this.latencyValue + "psec");
+ } else if (this.latencyValue < LATENCY1us) {
+ sb.append(Long.toString(this.latencyValue / LATENCY1ns) + "nsec");
+ } else if (this.latencyValue < LATENCY1ms) {
+ sb.append(Long.toString(this.latencyValue / LATENCY1us) + "usec");
+ } else if (this.latencyValue < LATENCY1s) {
+ sb.append(Long.toString(this.latencyValue / LATENCY1ms) + "msec");
}
sb.append("]");
import org.opendaylight.controller.sal.core.UpdateType;
import org.opendaylight.controller.sal.inventory.IInventoryService;
import org.opendaylight.controller.sal.inventory.IListenInventoryUpdates;
-import org.opendaylight.controller.sal.utils.HexEncode;
-import org.opendaylight.controller.sal.utils.StatusCode;
import org.opendaylight.controller.sal.utils.GlobalConstants;
+import org.opendaylight.controller.sal.utils.HexEncode;
import org.opendaylight.controller.sal.utils.IObjectReader;
import org.opendaylight.controller.sal.utils.ObjectReader;
import org.opendaylight.controller.sal.utils.ObjectWriter;
import org.opendaylight.controller.sal.utils.ServiceHelper;
import org.opendaylight.controller.sal.utils.Status;
+import org.opendaylight.controller.sal.utils.StatusCode;
import org.opendaylight.controller.switchmanager.IInventoryListener;
import org.opendaylight.controller.switchmanager.ISpanAware;
import org.opendaylight.controller.switchmanager.ISwitchManager;
public void startUp() {
// Initialize configuration file names
- subnetFileName = ROOT + "subnets" + this.getContainerName() + ".conf";
+ subnetFileName = ROOT + "subnets_" + this.getContainerName() + ".conf";
spanFileName = ROOT + "spanPorts_" + this.getContainerName() + ".conf";
switchConfigFileName = ROOT + "switchConfig_" + this.getContainerName()
+ ".conf";
}
public void shutDown() {
- destroyCaches(this.getContainerName());
}
@SuppressWarnings("deprecation")
}
conf.addNodeConnectors(switchPorts);
+ subnetsConfigList.put(name, conf);
// Update Database
Subnet sub = subnets.get(conf.getIPnum());
Set<NodeConnector> sp = conf.getNodeConnectors(switchPorts);
sub.addNodeConnectors(sp);
+ subnets.put(conf.getIPnum(), sub);
return new Status(StatusCode.SUCCESS, null);
}
return new Status(StatusCode.NOTFOUND, "Subnet does not exist");
}
conf.removeNodeConnectors(switchPorts);
+ subnetsConfigList.put(name, conf);
// Update Database
Subnet sub = subnets.get(conf.getIPnum());
Set<NodeConnector> sp = conf.getNodeConnectors(switchPorts);
sub.deleteNodeConnectors(sp);
+ subnets.put(conf.getIPnum(), sub);
return new Status(StatusCode.SUCCESS, null);
}
@SuppressWarnings("unchecked")
private void loadSubnetConfiguration() {
ObjectReader objReader = new ObjectReader();
- ConcurrentMap<Integer, SubnetConfig> confList = (ConcurrentMap<Integer, SubnetConfig>) objReader
+ ConcurrentMap<String, SubnetConfig> confList = (ConcurrentMap<String, SubnetConfig>) objReader
.read(this, subnetFileName);
if (confList == null) {
@Override
public void updateSwitchConfig(SwitchConfig cfgObject) {
+ // update default container only
+ if (!isDefaultContainer) {
+ return;
+ }
+
boolean modeChange = false;
SwitchConfig sc = nodeConfigList.get(cfgObject.getNodeId());
nodeConfigList.put(cfgObject.getNodeId(), cfgObject);
try {
- // update default container only
- if (isDefaultContainer) {
- String nodeId = cfgObject.getNodeId();
- Node node = Node.fromString(nodeId);
- Map<String, Property> propMap;
- if (nodeProps.get(node) != null) {
- propMap = nodeProps.get(node);
- } else {
- propMap = new HashMap<String, Property>();
- }
- 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);
+ String nodeId = cfgObject.getNodeId();
+ Node node = Node.fromString(nodeId);
+ Map<String, Property> propMap;
+ if (nodeProps.get(node) != null) {
+ propMap = nodeProps.get(node);
+ } else {
+ propMap = new HashMap<String, Property>();
+ }
+ 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);
- log.info("Set Node {}'s Mode to {}", nodeId,
- cfgObject.getMode());
+ log.info("Set Node {}'s Mode to {}", nodeId,
+ cfgObject.getMode());
- if (modeChange) {
- notifyModeChange(node, cfgObject.isProactive());
- }
+ if (modeChange) {
+ notifyModeChange(node, cfgObject.isProactive());
}
} catch (Exception e) {
log.debug("updateSwitchConfig: {}", e.getMessage());
addNodeProps(node, null);
}
- // check if span is configed
addSpanPort(nodeConnector);
break;
case REMOVED:
return;
}
- nodeProps = this.inventoryService.getNodeProps();
- Set<Node> nodeSet = nodeProps.keySet();
- if (nodeSet != null) {
- for (Node node : nodeSet) {
- log.debug("getInventories: {} added for container {}",
- new Object[] { node, containerName });
- addNode(node, null);
+ Map<Node, Map<String, Property>> nodeProp = this.inventoryService.getNodeProps();
+ for(Map.Entry<Node, Map<String, Property>> entry : nodeProp.entrySet()) {
+ Node node = entry.getKey();
+ log.debug("getInventories: {} added for container {}",
+ new Object[] { node, containerName });
+ Map<String, Property> propMap = entry.getValue();
+ Set<Property> props = new HashSet<Property>();
+ for(Property property : propMap.values()) {
+ props.add(property);
}
+ addNode(node, props);
}
- nodeConnectorProps = inventoryService.getNodeConnectorProps();
+ Map<NodeConnector, Map<String, Property>> nodeConnectorProp = this.inventoryService.getNodeConnectorProps();
+ for(Map.Entry<NodeConnector, Map<String, Property>> entry : nodeConnectorProp.entrySet()) {
+ Map<String, Property> propMap = entry.getValue();
+ for(Property property : propMap.values()) {
+ addNodeConnectorProp(entry.getKey(), property);
+ }
+ }
}
private void clearInventories() {
/*
* Add span configuration to local cache and notify clients
*/
- private void addSpanPorts(Node node, List<NodeConnector> nodeConncetors) {
+ private void addSpanPorts(Node node, List<NodeConnector> nodeConnectors) {
List<NodeConnector> ncLists = new ArrayList<NodeConnector>();
- for (NodeConnector nodeConnector : nodeConncetors) {
+ for (NodeConnector nodeConnector : nodeConnectors) {
if (!spanNodeConnectors.contains(nodeConnector)) {
ncLists.add(nodeConnector);
}
}
}
- private void addSpanPort(NodeConnector nodeConncetor) {
- List<NodeConnector> ncLists = new ArrayList<NodeConnector>();
- ncLists.add(nodeConncetor);
- addSpanPorts(nodeConncetor.getNode(), ncLists);
+ private void addSpanPort(NodeConnector nodeConnector) {
+ // only add if span is configured on this nodeConnector
+ for (SpanConfig conf : getSpanConfigList(nodeConnector.getNode())) {
+ if (conf.getPortArrayList().contains(nodeConnector)) {
+ List<NodeConnector> ncLists = new ArrayList<NodeConnector>();
+ ncLists.add(nodeConnector);
+ addSpanPorts(nodeConnector.getNode(), ncLists);
+ return;
+ }
+ }
}
/*
* Remove span configuration to local cache and notify clients
*/
- private void removeSpanPorts(Node node, List<NodeConnector> nodeConncetors) {
+ private void removeSpanPorts(Node node, List<NodeConnector> nodeConnectors) {
List<NodeConnector> ncLists = new ArrayList<NodeConnector>();
- for (NodeConnector nodeConnector : nodeConncetors) {
+ for (NodeConnector nodeConnector : nodeConnectors) {
if (spanNodeConnectors.contains(nodeConnector)) {
ncLists.add(nodeConnector);
}
}
}
- private void removeSpanPort(NodeConnector nodeConncetor) {
- List<NodeConnector> ncLists = new ArrayList<NodeConnector>();
- ncLists.add(nodeConncetor);
- removeSpanPorts(nodeConncetor.getNode(), ncLists);
+ private void removeSpanPort(NodeConnector nodeConnector) {
+ if (spanNodeConnectors.contains(nodeConnector)) {
+ List<NodeConnector> ncLists = new ArrayList<NodeConnector>();
+ ncLists.add(nodeConnector);
+ removeSpanPorts(nodeConnector.getNode(), ncLists);
+ }
}
private void addNodeProps(Node node, Map<String, Property> propMap) {