Bug 6143: Fixed bug that failed to put vtn-data-flow into clustered DS. 14/41214/1
authorShigeru Yasuda <s-yasuda@da.jp.nec.com>
Fri, 1 Jul 2016 13:12:13 +0000 (22:12 +0900)
committerShigeru Yasuda <s-yasuda@da.jp.nec.com>
Fri, 1 Jul 2016 13:12:13 +0000 (22:12 +0900)
This patch fixes a bug that sets an invalid vtn-flow-id into vtn-data-flow
if DS transaction for adding data flow is re-executed due to data
confliction.

Change-Id: I6ef168e396c148daab8cf95b4cf2506b71108401
Signed-off-by: Shigeru Yasuda <s-yasuda@da.jp.nec.com>
manager/implementation/src/main/java/org/opendaylight/vtn/manager/internal/flow/add/PutFlowTxTask.java
manager/implementation/src/main/java/org/opendaylight/vtn/manager/internal/util/flow/VTNFlowBuilder.java

index 7f9f2035508b6ec359df7bc4b8af13fe68792ebe..8a54431cc4a3d59d806cd5e7476c28445fe48509 100644 (file)
@@ -156,9 +156,9 @@ public final class PutFlowTxTask extends AbstractTxTask<VtnDataFlow> {
                 id = MIN_FLOW_ID;
             }
 
+            VtnFlowId nextId = new VtnFlowId(BigInteger.valueOf(id));
             if (!fopt.isPresent()) {
                 // Update the next-flow-id for the next allocation.
-                VtnFlowId nextId = new VtnFlowId(BigInteger.valueOf(id));
                 NextFlowId nfid = new NextFlowIdBuilder().
                     setNextId(nextId).build();
                 tx.put(oper, NEXT_FLOW_ID_PATH, nfid, true);
@@ -166,6 +166,7 @@ public final class PutFlowTxTask extends AbstractTxTask<VtnDataFlow> {
                 return flowId;
             }
 
+            flowId = nextId;
         } while (id != start);
 
         flowPath = null;
index 14821ab01820b9dd1847d9cc4b212de575e2c79c..6f8d1f320558d8f8ca94ff445631c9a45f3295d5 100644 (file)
@@ -301,24 +301,26 @@ public final class VTNFlowBuilder implements VTNDataFlow {
      */
     public VtnDataFlow createVtnDataFlow(VtnFlowId fid) {
         if (dataFlow == null) {
-            // Configure flow entries.
-            int order = MiscUtils.ORDER_MIN;
-            FlowCookie cookie = FlowUtils.createCookie(fid);
-            List<VtnFlowEntry> entries = new ArrayList<>(flowEntries.size());
-            for (VtnFlowEntryBuilder flow: flowEntries) {
-                entries.add(flow.setCookie(cookie).setOrder(order).build());
-                order++;
-            }
+            // Configure virtual node hop.
+            flowBuilder.setVirtualRoute(
+                VNodeHop.toVirtualRouteList(virtualRoute));
+        }
 
-            // Configure VTN data flow.
-            flowBuilder.setFlowId(fid).
-                setVirtualRoute(VNodeHop.toVirtualRouteList(virtualRoute)).
-                setVtnFlowEntry(entries);
+        // Configure flow entries.
+        int order = MiscUtils.ORDER_MIN;
+        FlowCookie cookie = FlowUtils.createCookie(fid);
+        List<VtnFlowEntry> entries = new ArrayList<>(flowEntries.size());
+        for (VtnFlowEntryBuilder flow: flowEntries) {
+            entries.add(flow.setCookie(cookie).setOrder(order).build());
+            order++;
         }
 
-        // Update the creation time.
+        // Configure VTN data flow.
         Long created = Long.valueOf(System.currentTimeMillis());
-        dataFlow = flowBuilder.setCreationTime(created).build();
+        dataFlow = flowBuilder.setFlowId(fid).
+            setVtnFlowEntry(entries).
+            setCreationTime(created).
+            build();
 
         return dataFlow;
     }