Merge "Restoring basic cache syncing for switch manager Signed-off-by: Pramila Singh...
authorAlessandro Boch <aboch@cisco.com>
Tue, 2 Jul 2013 17:46:41 +0000 (17:46 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 2 Jul 2013 17:46:41 +0000 (17:46 +0000)
opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowConfig.java
opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManagerImpl.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Latency.java

index 8a77825d7943c12e8be971687cb4f3e8ac187b72..2b9696ddb9cdf058640caa671735757556fb1a5a 100644 (file)
@@ -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) {
index e9c0edc3bde98fb75bbc27663d2c2d24c215756b..2c5144f284b908f46d2a114da4acf2f2c3a14a58 100644 (file)
@@ -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) {
index 61e3872669b67f6a01f955bf2d15780635e0c84a..818002a21e042f87da32f5e14573e1b502ffc328 100644 (file)
@@ -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("]");