From: Alessandro Boch Date: Tue, 2 Jul 2013 17:47:02 +0000 (+0000) Subject: Merge "Add help menu" X-Git-Tag: releasepom-0.1.0~318 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=7aac9c5fcb0f617c6b15e527f3c0f3d87032b83a;hp=24e6b66c28a9d26e18b805138d808069283dc3b8 Merge "Add help menu" --- diff --git a/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowConfig.java b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowConfig.java index 8a77825d79..2b9696ddb9 100644 --- a/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowConfig.java +++ b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowConfig.java @@ -730,8 +730,8 @@ public class FlowConfig implements Serializable { Short port = Short.decode(ingressPort); if (isPortValid(sw, port) == false) { String msg = String.format("Ingress port %d is not valid for the Switch", port); - if ((container != null) && !container.getName().equals(GlobalConstants.DEFAULT.toString())) { - msg += " in Container " + container.getName(); + if (!containerName.equals(GlobalConstants.DEFAULT.toString())) { + msg += " in Container " + containerName; } return new Status(StatusCode.BADREQUEST, msg); } @@ -841,9 +841,8 @@ public class FlowConfig implements Serializable { Short port = Short.parseShort(n.group(1)); if (isPortValid(sw, port) == false) { String msg = String.format("Output port %d is not valid for this switch", port); - if ((container != null) - && !container.getName().equals(GlobalConstants.DEFAULT.toString())) { - msg += " in Container " + container.getName(); + if (!containerName.equals(GlobalConstants.DEFAULT.toString())) { + msg += " in Container " + containerName; } return new Status(StatusCode.BADREQUEST, msg); } @@ -855,9 +854,9 @@ public class FlowConfig implements Serializable { // Check src IP sstr = Pattern.compile(ActionType.FLOOD.toString()).matcher(actiongrp); if (sstr.matches()) { - if (container != null) { + if (!containerName.equals(GlobalConstants.DEFAULT.toString())) { return new Status(StatusCode.BADREQUEST, String.format( - "flood is not allowed in container %s", container.getName())); + "flood is not allowed in container %s", containerName)); } continue; } @@ -955,7 +954,7 @@ public class FlowConfig implements Serializable { } // Check against the container flow Status status; - if ((container != null) && !(status = conflictWithContainerFlow(container)).isSuccess()) { + if (!containerName.equals(GlobalConstants.DEFAULT.toString()) && !(status = conflictWithContainerFlow(container)).isSuccess()) { return status; } } catch (NumberFormatException e) { diff --git a/opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerImpl.java b/opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerImpl.java index e9c0edc3bd..2c5144f284 100644 --- a/opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerImpl.java +++ b/opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerImpl.java @@ -1444,7 +1444,7 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, Port } // Program the network node - Status status = this.removeEntry(config.getFlowEntry(), false); + Status status = this.uninstallFlowEntry(config.getFlowEntry()); // Update configuration database if programming was successful if (status.isSuccess()) { @@ -1543,7 +1543,7 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, Port // If flow is installed, program the network node status = new Status(StatusCode.SUCCESS, "Saved in config"); if (oldFlowConfig.installInHw()) { - status = this.modifyEntry(oldFlowConfig.getFlowEntry(), newFlowConfig.getFlowEntry(), false); + status = this.modifyFlowEntry(oldFlowConfig.getFlowEntry(), newFlowConfig.getFlowEntry()); } // Update configuration database if programming was successful @@ -1588,16 +1588,14 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, Port } if (target != null) { // Program the network node - Status status; - if (target.installInHw()) { - status = this.removeEntry(target.getFlowEntry(), false); - } else { - status = this.addEntry(target.getFlowEntry(), false); + Status status = (target.installInHw()) ? this.uninstallFlowEntry(target.getFlowEntry()) : this + .installFlowEntry(target.getFlowEntry()); + if (status.isSuccess()) { + // Update Configuration database + target.setStatus(SUCCESS); + target.toggleInstallation(); + staticFlows.put(key, target); } - // Update Configuration database - target.setStatus(SUCCESS); - target.toggleInstallation(); - staticFlows.put(key, target); return status; } @@ -2191,11 +2189,10 @@ public class ForwardingRulesManagerImpl implements IForwardingRulesManager, Port * 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() { - // Set graceful stop flag stopping = true; + uninstallAllFlowEntries(); } public void setFlowProgrammerService(IFlowProgrammerService service) { diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Latency.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Latency.java index 61e3872669..818002a21e 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Latency.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Latency.java @@ -9,6 +9,7 @@ package org.opendaylight.controller.sal.core; +import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; /** @@ -21,7 +22,9 @@ 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); @@ -40,37 +43,37 @@ public class Latency extends Property { */ 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; } @@ -83,7 +86,7 @@ public class Latency extends Property { if (getClass() != obj.getClass()) return false; Latency other = (Latency) obj; - if (latency != other.latency) + if (latencyValue != other.latencyValue) return false; return true; } @@ -93,16 +96,16 @@ public class Latency extends Property { 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("]"); diff --git a/opendaylight/samples/simpleforwarding/pom.xml b/opendaylight/samples/simpleforwarding/pom.xml index fd288c7127..14e440df02 100644 --- a/opendaylight/samples/simpleforwarding/pom.xml +++ b/opendaylight/samples/simpleforwarding/pom.xml @@ -40,6 +40,9 @@ org.slf4j, org.apache.felix.dm + + org.opendaylight.controller.sample.simpleforwarding + org.opendaylight.controller.samples.simpleforwarding.internal.Activator diff --git a/opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/internal/HostNodePair.java b/opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/HostNodePair.java similarity index 97% rename from opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/internal/HostNodePair.java rename to opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/HostNodePair.java index afbbec998d..2d0d468466 100644 --- a/opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/internal/HostNodePair.java +++ b/opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/HostNodePair.java @@ -7,7 +7,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.controller.samples.simpleforwarding.internal; +package org.opendaylight.controller.samples.simpleforwarding; import java.io.Serializable; diff --git a/opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/internal/SimpleForwardingImpl.java b/opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/internal/SimpleForwardingImpl.java index 11056478db..7f4c98a648 100644 --- a/opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/internal/SimpleForwardingImpl.java +++ b/opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/internal/SimpleForwardingImpl.java @@ -50,12 +50,15 @@ import org.opendaylight.controller.sal.routing.IRouting; import org.opendaylight.controller.sal.utils.EtherTypes; import org.opendaylight.controller.sal.utils.NodeConnectorCreator; import org.opendaylight.controller.sal.utils.Status; +import org.opendaylight.controller.samples.simpleforwarding.HostNodePair; import org.opendaylight.controller.switchmanager.IInventoryListener; import org.opendaylight.controller.switchmanager.ISwitchManager; import org.opendaylight.controller.topologymanager.ITopologyManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + + public class SimpleForwardingImpl implements IfNewHostNotify, IListenRoutingUpdates, IInventoryListener { private static Logger log = LoggerFactory diff --git a/opendaylight/samples/simpleforwarding/src/test/java/org/opendaylight/controller/samples/simpleforwarding/internal/HostSwitchTest.java b/opendaylight/samples/simpleforwarding/src/test/java/org/opendaylight/controller/samples/simpleforwarding/internal/HostSwitchTest.java index afa4c42d36..7897c39890 100644 --- a/opendaylight/samples/simpleforwarding/src/test/java/org/opendaylight/controller/samples/simpleforwarding/internal/HostSwitchTest.java +++ b/opendaylight/samples/simpleforwarding/src/test/java/org/opendaylight/controller/samples/simpleforwarding/internal/HostSwitchTest.java @@ -18,7 +18,8 @@ import org.junit.Assert; import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector; import org.opendaylight.controller.sal.core.ConstructionException; import org.opendaylight.controller.sal.utils.NodeCreator; -import org.opendaylight.controller.samples.simpleforwarding.internal.HostNodePair; +import org.opendaylight.controller.samples.simpleforwarding.HostNodePair; + public class HostSwitchTest { @Test diff --git a/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SpanConfig.java b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SpanConfig.java index 80ed209819..83cb8b1cc9 100644 --- a/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SpanConfig.java +++ b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SpanConfig.java @@ -150,4 +150,9 @@ public class SpanConfig implements Serializable { public boolean matchNode(String nodeId) { return this.nodeId.equals(nodeId); } + + @Override + public String toString() { + return ("Span Config [nodeId=" + nodeId + " spanPort=" + spanPort + "]"); + } } diff --git a/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SubnetConfig.java b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SubnetConfig.java index 87dd99da7f..895f117321 100644 --- a/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SubnetConfig.java +++ b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SubnetConfig.java @@ -231,6 +231,7 @@ public class SubnetConfig implements Serializable { nodePorts.remove(sp); } + @Override public String toString() { return ("Subnet Config [Description=" + name + " Subnet=" + subnet + " NodeConnectors=" + nodePorts + "]"); diff --git a/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SwitchConfig.java b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SwitchConfig.java index 253096edc3..61b2f0a3a8 100644 --- a/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SwitchConfig.java +++ b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SwitchConfig.java @@ -97,4 +97,10 @@ public class SwitchConfig implements Serializable { return false; return true; } + + @Override + public String toString() { + return ("Switch Config [Node=" + nodeId + " Description=" + description + + " Tier=" + tier + " Mode=" + mode + "]"); + } } diff --git a/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java b/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java index ab31496103..d32f98650b 100644 --- a/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java +++ b/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java @@ -52,14 +52,14 @@ import org.opendaylight.controller.sal.core.Tier; 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; @@ -174,7 +174,7 @@ CommandProvider { 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"; @@ -201,7 +201,6 @@ CommandProvider { } public void shutDown() { - destroyCaches(this.getContainerName()); } @SuppressWarnings("deprecation") @@ -499,11 +498,13 @@ CommandProvider { } conf.addNodeConnectors(switchPorts); + subnetsConfigList.put(name, conf); // Update Database Subnet sub = subnets.get(conf.getIPnum()); Set sp = conf.getNodeConnectors(switchPorts); sub.addNodeConnectors(sp); + subnets.put(conf.getIPnum(), sub); return new Status(StatusCode.SUCCESS, null); } @@ -515,11 +516,13 @@ CommandProvider { 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 sp = conf.getNodeConnectors(switchPorts); sub.deleteNodeConnectors(sp); + subnets.put(conf.getIPnum(), sub); return new Status(StatusCode.SUCCESS, null); } @@ -554,7 +557,7 @@ CommandProvider { @SuppressWarnings("unchecked") private void loadSubnetConfiguration() { ObjectReader objReader = new ObjectReader(); - ConcurrentMap confList = (ConcurrentMap) objReader + ConcurrentMap confList = (ConcurrentMap) objReader .read(this, subnetFileName); if (confList == null) { @@ -598,6 +601,11 @@ CommandProvider { @Override public void updateSwitchConfig(SwitchConfig cfgObject) { + // update default container only + if (!isDefaultContainer) { + return; + } + boolean modeChange = false; SwitchConfig sc = nodeConfigList.get(cfgObject.getNodeId()); @@ -607,28 +615,25 @@ CommandProvider { nodeConfigList.put(cfgObject.getNodeId(), cfgObject); try { - // update default container only - if (isDefaultContainer) { - String nodeId = cfgObject.getNodeId(); - Node node = Node.fromString(nodeId); - Map propMap; - if (nodeProps.get(node) != null) { - propMap = nodeProps.get(node); - } else { - propMap = new HashMap(); - } - 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 propMap; + if (nodeProps.get(node) != null) { + propMap = nodeProps.get(node); + } else { + propMap = new HashMap(); + } + 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()); @@ -1333,17 +1338,26 @@ CommandProvider { return; } - nodeProps = this.inventoryService.getNodeProps(); - Set nodeSet = nodeProps.keySet(); - if (nodeSet != null) { - for (Node node : nodeSet) { - log.debug("getInventories: {} added for container {}", - new Object[] { node, containerName }); - addNode(node, null); + Map> nodeProp = this.inventoryService.getNodeProps(); + for(Map.Entry> entry : nodeProp.entrySet()) { + Node node = entry.getKey(); + log.debug("getInventories: {} added for container {}", + new Object[] { node, containerName }); + Map propMap = entry.getValue(); + Set props = new HashSet(); + for(Property property : propMap.values()) { + props.add(property); } + addNode(node, props); } - nodeConnectorProps = inventoryService.getNodeConnectorProps(); + Map> nodeConnectorProp = this.inventoryService.getNodeConnectorProps(); + for(Map.Entry> entry : nodeConnectorProp.entrySet()) { + Map propMap = entry.getValue(); + for(Property property : propMap.values()) { + addNodeConnectorProp(entry.getKey(), property); + } + } } private void clearInventories() {