Fix for Bug:399 25/5225/3
authorSachi <sachi.gupta@tcs.com>
Mon, 10 Feb 2014 10:16:02 +0000 (15:46 +0530)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 10 Feb 2014 11:06:21 +0000 (11:06 +0000)
Bug Description: Northbound doesn't allow priority and multicastPriority values to be set to 255
Changes Made For: Northbound and Southbound allow priority and multicastPriority values to be set betweeen 0 and 255.

Change-Id: I3fb1191ce63b9b1cfb27aae61ba608065514e86e
Signed-off-by: Sachi <sachi.gupta@tcs.com>
mappingservice/api/pom.xml
mappingservice/api/src/main/java/org/opendaylight/lispflowmapping/type/lisp/LocatorRecord.java
mappingservice/implementation/ms.impl-tests.launch

index e7032c7242399a4ddf3ce049e53bd56b63ff7f56..029910732b3000a96bad3c72029c5ca39067ecb7 100644 (file)
@@ -49,7 +49,8 @@
                                                        javax.xml.bind,
                                                        javax.xml.bind.annotation,
                                                        org.slf4j,
-                                                       org.opendaylight.yangtools.yang.common
+                                                       org.opendaylight.yangtools.yang.common,
+                                                       com.google.common.collect
                                                </Import-Package>
                                                <Bundle-Activator>
                                                </Bundle-Activator>
                                        </instructions>
                                </configuration>
                        </plugin>
+                       <plugin>
+                               <groupId>org.codehaus.mojo</groupId>
+                               <artifactId>build-helper-maven-plugin</artifactId>
+                       </plugin>
                </plugins>
        </build>
        <dependencies>
index 4bab00183c06c93293815cb6ca3158ecd2e373e9..f2501c201cafd473085899c543f44799a97b0deb 100644 (file)
@@ -8,6 +8,9 @@
 
 package org.opendaylight.lispflowmapping.type.lisp;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
@@ -16,6 +19,8 @@ import javax.xml.bind.annotation.XmlRootElement;
 import org.opendaylight.lispflowmapping.type.lisp.address.LispAddress;
 import org.opendaylight.lispflowmapping.type.lisp.address.LispAddressGeneric;
 
+import com.google.common.collect.Range;
+
 /**
  * <pre>
  *        0                   1                   2                   3
@@ -51,7 +56,7 @@ public class LocatorRecord {
      * for unicast forwarding.
      */
     @XmlElement
-    private byte priority;
+    private short priority;
     /**
      * Weight: When priorities are the same for multiple RLOCs, the Weight
      * indicates how to balance unicast traffic between them. Weight is encoded
@@ -75,7 +80,7 @@ public class LocatorRecord {
      * see [RFC6831].
      */
     @XmlElement
-    private byte multicastPriority;
+    private short multicastPriority;
     /**
      * M Weight: When priorities are the same for multiple RLOCs, the Weight
      * indicates how to balance building multicast distribution trees across
@@ -144,13 +149,26 @@ public class LocatorRecord {
         return locatorGeneric;
     }
 
-    public byte getPriority() {
+    public short getPriority() {
         return priority;
     }
 
-    public LocatorRecord setPriority(byte priority) {
-        this.priority = priority;
-        return this;
+    public LocatorRecord setPriority(short priority) {
+        if (priority != 0) {
+             boolean isValidRange = false;
+             List<Range<Short>> rangeConstraints = new ArrayList<>(); 
+             rangeConstraints.add(Range.closed(new Short("0"), new Short("255")));
+             for (Range<Short> r : rangeConstraints) {
+                 if (r.contains(priority)) {
+                 isValidRange = true;
+                 }
+             }
+             if (!isValidRange) {
+                 throw new IllegalArgumentException(String.format("Invalid range: %s, expected: %s.", priority, rangeConstraints));
+             }
+         }    
+         this.priority = priority;
+         return this;
     }
 
     public byte getWeight() {
@@ -162,12 +180,25 @@ public class LocatorRecord {
         return this;
     }
 
-    public byte getMulticastPriority() {
+    public short getMulticastPriority() {
         return multicastPriority;
     }
 
-    public LocatorRecord setMulticastPriority(byte multicastPriority) {
-        this.multicastPriority = multicastPriority;
+    public LocatorRecord setMulticastPriority(short value) {
+       if (value != 0) {
+            boolean isValidRange = false;
+            List<Range<Short>> rangeConstraints = new ArrayList<>(); 
+            rangeConstraints.add(Range.closed(new Short("0"), new Short("255")));
+            for (Range<Short> r : rangeConstraints) {
+                if (r.contains(value)) {
+                isValidRange = true;
+                }
+            }
+            if (!isValidRange) {
+                throw new IllegalArgumentException(String.format("Invalid range: %s, expected: %s.", value, rangeConstraints));
+            }
+        }    
+        this.multicastPriority = value;
         return this;
     }
 
index a0ce3e68a34fab3d18985b376b7e1b5fb6fc1ae8..7bbd0257db2874a13f5a7949298f1ac1049bcf6f 100644 (file)
@@ -16,4 +16,5 @@
 <stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
 <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
 <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="mappingservice.implementation"/>
+<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
 </launchConfiguration>