* Add FlowPathFlags to the FlowPath header.
* Implement DISCARD_FIRST_HOP_ENTRY and KEEP_ONLY_FIRST_HOP_ENTRY flags:
- DISCARD_FIRST_HOP_ENTRY : After computing the shortest-path, the
first-hop entry is discarded
- KEEP_ONLY_FIRST_HOP_ENTRY : After computing the shortest-path,
only the the first hop entry is kept, and the rest are discarded.
diff --git a/src/test/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjectsIFlowPathTest.java b/src/test/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjectsIFlowPathTest.java
index 85072e3..bb0dbbf 100644
--- a/src/test/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjectsIFlowPathTest.java
+++ b/src/test/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjectsIFlowPathTest.java
@@ -104,6 +104,24 @@
/**
* Desc:
+ * Test method for get and set FlowPathFlags method.
+ * Condition:
+ * N/A
+ * Expect:
+ * 1. Should set the Flow Path Flags.
+ * 2. Should get the Flow Path Flags.
+ */
+ @Test
+ public void testSetGetFlowPathFlags() {
+ String flowId = "xx";
+ Long flowPathFlags = new Long(0x3);
+ flowPath.setFlowId(flowId);
+ flowPath.setFlowPathFlags(flowPathFlags);
+ assertEquals(flowPath.getFlowPathFlags(), flowPathFlags);
+ }
+
+ /**
+ * Desc:
* Test method for get and set SourceSwitch method.
* Condition:
* N/A
diff --git a/src/test/java/net/onrc/onos/ofcontroller/core/internal/TestableGraphDBOperation.java b/src/test/java/net/onrc/onos/ofcontroller/core/internal/TestableGraphDBOperation.java
index fb5227f..f746060 100644
--- a/src/test/java/net/onrc/onos/ofcontroller/core/internal/TestableGraphDBOperation.java
+++ b/src/test/java/net/onrc/onos/ofcontroller/core/internal/TestableGraphDBOperation.java
@@ -415,6 +415,7 @@
public static class TestFlowPath implements IFlowPath {
private String state,type,flowId,installerId,srcSw,dstSw;
+ private Long flowPathFlags;
private String dataPathSummary,userState;
private Short srcPort,dstPort;
private String matchSrcMac,matchDstMac;
@@ -429,6 +430,7 @@
private List<ISwitchObject> switches;
private String stateToUpdate,typeToUpdate,flowIdToUpdate,installerIdToUpdate,srcSwToUpdate,dstSwToUpdate;
+ private Long flowPathFlagsToUpdate;
private String dataPathSummaryToUpdate,userStateToUpdate;
private Short srcPortToUpdate,dstPortToUpdate;
private String matchSrcMacToUpdate,matchDstMacToUpdate;
@@ -465,6 +467,7 @@
if(typeToUpdate != null) { type = typeToUpdate; }
if(flowIdToUpdate != null) { flowId = flowIdToUpdate; }
if(installerIdToUpdate != null) { installerId = installerIdToUpdate; }
+ if(flowPathFlagsToUpdate != null) { flowPathFlags = flowPathFlagsToUpdate; }
if(srcSwToUpdate != null) { srcSw = srcSwToUpdate; }
if(dstSwToUpdate != null) { dstSw = dstSwToUpdate; }
if(dataPathSummaryToUpdate != null) { dataPathSummary = dataPathSummaryToUpdate; }
@@ -493,6 +496,7 @@
flowsToRemove.clear();
stateToUpdate = typeToUpdate = flowIdToUpdate = installerIdToUpdate = null;
+ flowPathFlagsToUpdate = null;
srcSwToUpdate = dstSwToUpdate = dataPathSummaryToUpdate = userStateToUpdate = null;
srcPortToUpdate = dstPortToUpdate = null;
matchSrcMacToUpdate = matchDstMacToUpdate = null;
@@ -509,6 +513,7 @@
public void setTypeForTest(String type) { this.type = type; }
public void setFlowIdForTest(String flowId) { this.flowId = flowId; }
public void setInstallerIdForTest(String installerId) { this.installerId = installerId; }
+ public void setFlowPathFlagsForTest(Long flowPathFlags) { this.flowPathFlags = flowPathFlags; }
public void setSrcSwForTest(String srcSw) { this.srcSw = srcSw; }
public void setDstSwForTest(String dstSw) { this.dstSw = dstSw; }
public void setDataPathSummaryForTest(String dataPathSummary) { this.dataPathSummary = dataPathSummary; }
@@ -560,6 +565,12 @@
public void setInstallerId(String installerId) { installerIdToUpdate = installerId; }
@Override
+ public Long getFlowPathFlags() { return flowPathFlags; }
+
+ @Override
+ public void setFlowPathFlags(Long flowPathFlags) { flowPathFlagsToUpdate = flowPathFlags; }
+
+ @Override
public String getSrcSwitch() { return srcSw; }
@Override
diff --git a/src/test/java/net/onrc/onos/ofcontroller/flowmanager/FlowManagerTest.java b/src/test/java/net/onrc/onos/ofcontroller/flowmanager/FlowManagerTest.java
index 750bfba..cacedd2 100644
--- a/src/test/java/net/onrc/onos/ofcontroller/flowmanager/FlowManagerTest.java
+++ b/src/test/java/net/onrc/onos/ofcontroller/flowmanager/FlowManagerTest.java
@@ -80,10 +80,12 @@
}
private IFlowPath createIFlowPathMock(long flowId, String installerID,
+ long flowPathFlags,
long srcDpid, int srcPort, long dstDpid, int dstPort) {
IFlowPath iFlowPath = createNiceMock(IFlowPath.class);
expect(iFlowPath.getFlowId()).andReturn(new FlowId(flowId).toString()).anyTimes();
expect(iFlowPath.getInstallerId()).andReturn(installerID).anyTimes();
+ expect(iFlowPath.getFlowPathFlags()).andReturn(new Long(flowPathFlags)).anyTimes();
expect(iFlowPath.getSrcSwitch()).andReturn(new Dpid(srcDpid).toString()).anyTimes();
expect(iFlowPath.getSrcPort()).andReturn(new Short((short)srcPort)).anyTimes();
expect(iFlowPath.getDstSwitch()).andReturn(new Dpid(dstDpid).toString()).anyTimes();
@@ -92,12 +94,14 @@
}
private FlowPath createTestFlowPath(long flowId, String installerId,
+ final long flowPathFlags,
final long srcDpid, final int srcPort,
final long dstDpid, final int dstPort
) {
FlowPath flowPath = new FlowPath();
flowPath.setFlowId(new FlowId(flowId));
flowPath.setInstallerId(new CallerId(installerId));
+ flowPath.setFlowPathFlags(new FlowPathFlags(flowPathFlags));
flowPath.setDataPath(new DataPath() {{
setSrcPort(new SwitchPort(new Dpid(srcDpid), new Port((short)srcPort)));
setDstPort(new SwitchPort(new Dpid(dstDpid), new Port((short)dstPort)));
@@ -107,9 +111,9 @@
}
private ArrayList<FlowPath> createTestFlowPaths() {
- FlowPath flowPath1 = createTestFlowPath(1, "foo caller id", 1, 1, 2, 2);
- FlowPath flowPath2 = createTestFlowPath(2, "caller id", 1, 1, 2, 2);
- FlowPath flowPath3 = createTestFlowPath(3, "caller id", 1, 5, 2, 2);
+ FlowPath flowPath1 = createTestFlowPath(1, "foo caller id", 0, 1, 1, 2, 2);
+ FlowPath flowPath2 = createTestFlowPath(2, "caller id", 0, 1, 1, 2, 2);
+ FlowPath flowPath3 = createTestFlowPath(3, "caller id", 0, 1, 5, 2, 2);
ArrayList<FlowPath> flowPaths = new ArrayList<FlowPath>();
flowPaths.add(flowPath1);
@@ -182,6 +186,7 @@
FlowPath flowPath = new FlowPath();
flowPath.setFlowId(new FlowId(0x100));
flowPath.setInstallerId(new CallerId("installer id"));
+ flowPath.setFlowPathFlags(new FlowPathFlags(0));
flowPath.setDataPath(dataPath);
flowPath.setFlowEntryMatch(match);
@@ -192,6 +197,7 @@
createdFlowPath.setFlowId("0x100");
createdFlowPath.setType("flow");
createdFlowPath.setInstallerId("installer id");
+ createdFlowPath.setFlowPathFlags(new Long((long)0));
createdFlowPath.setSrcSwitch("00:00:00:00:00:00:12:34");
createdFlowPath.setSrcPort(new Short((short)1));
createdFlowPath.setDstSwitch("00:00:00:00:00:00:56:78");
@@ -339,7 +345,7 @@
public final void testGetFlowSuccessNormally() throws Exception {
// instantiate required objects
FlowManager fm = new FlowManager();
- IFlowPath iFlowPath = createIFlowPathMock(1, "caller id", 1, 1, 2, 2);
+ IFlowPath iFlowPath = createIFlowPathMock(1, "caller id", 0, 1, 1, 2, 2);
// setup expectations
expectInitWithContext();
@@ -351,11 +357,14 @@
replayAll();
fm.init(context);
- String result = fm.getFlow(new FlowId(1)).installerId().toString();
+ FlowPath flowPath = fm.getFlow(new FlowId(1));
+ String installerId = flowPath.installerId().toString();
+ long flowPathFlags = flowPath.flowPathFlags().flags();
//verify the test
verifyAll();
- assertEquals("caller id", result);
+ assertEquals("caller id", installerId);
+ assertEquals(0L, flowPathFlags);
}
/**
@@ -437,9 +446,9 @@
final String getAllFlowsWithoutFlowEntries = "getAllFlowsWithoutFlowEntries";
// create mock objects
FlowManager fm = createPartialMockAndInvokeDefaultConstructor(FlowManager.class, getAllFlowsWithoutFlowEntries);
- IFlowPath flowPath1 = createIFlowPathMock(1, "", 1, 2, 3, 4);
- IFlowPath flowPath2 = createIFlowPathMock(5, "", 2, 3, 4, 5);
- IFlowPath flowPath3 = createIFlowPathMock(10, "", 3, 4, 5, 6);
+ IFlowPath flowPath1 = createIFlowPathMock(1, "", 0, 1, 2, 3, 4);
+ IFlowPath flowPath2 = createIFlowPathMock(5, "", 0, 2, 3, 4, 5);
+ IFlowPath flowPath3 = createIFlowPathMock(10, "", 0, 3, 4, 5, 6);
// instantiate required objects
ArrayList<IFlowPath> flows = new ArrayList<IFlowPath>();
@@ -472,8 +481,8 @@
@Test
public final void testGetAllFlowsSuccessNormally() throws Exception {
// create mock objects
- IFlowPath iFlowPath1 = createIFlowPathMock(1, "caller id", 1, 1, 2, 2);
- IFlowPath iFlowPath2 = createIFlowPathMock(2, "caller id", 2, 5, 3, 5);
+ IFlowPath iFlowPath1 = createIFlowPathMock(1, "caller id", 0, 1, 1, 2, 2);
+ IFlowPath iFlowPath2 = createIFlowPathMock(2, "caller id", 0, 2, 5, 3, 5);
// instantiate required objects
ArrayList<IFlowPath> flowPaths = new ArrayList<IFlowPath>();
@@ -524,6 +533,7 @@
FlowPath paramFlow = new FlowPath();
paramFlow.setFlowId(new FlowId(100));
paramFlow.setInstallerId(new CallerId("installer id"));
+ paramFlow.setFlowPathFlags(new FlowPathFlags(0));
paramFlow.setDataPath(dataPath);
paramFlow.setFlowEntryMatch(match);
@@ -538,6 +548,7 @@
FlowPath flowPath = (FlowPath)EasyMock.getCurrentArguments()[0];
assertEquals(flowPath.flowId().value(), 100);
assertEquals(flowPath.installerId().toString(), "installer id");
+ assertEquals(flowPath.flowPathFlags().flags(), 0);
assertEquals(flowPath.dataPath().srcPort().toString(),
new SwitchPort(new Dpid(1), new Port((short)3)).toString());
@@ -558,6 +569,7 @@
verifyAll();
assertEquals(paramFlow.flowId().value(), resultFlow.flowId().value());
assertEquals(paramFlow.installerId().toString(), resultFlow.installerId().toString());
+ assertEquals(paramFlow.flowPathFlags().flags(), resultFlow.flowPathFlags().flags());
assertEquals(paramFlow.dataPath().toString(), resultFlow.dataPath().toString());
assertEquals(paramFlow.flowEntryMatch().toString(), resultFlow.flowEntryMatch().toString());
}
@@ -569,7 +581,7 @@
@Test
public final void testMeasurementStorePathFlowSuccessNormally() throws Exception {
// instantiate required objects
- FlowPath paramFlow = createTestFlowPath(100, "installer id", 1, 3, 2, 4);
+ FlowPath paramFlow = createTestFlowPath(100, "installer id", 0, 1, 3, 2, 4);
Map<Long, Object> shortestPathMap = new HashMap<Long, Object>();
FlowManager fm = new FlowManager();
@@ -592,6 +604,7 @@
verifyAll();
assertEquals(paramFlow.flowId().value(), resultFlowPath.flowId().value());
assertEquals(paramFlow.installerId().toString(), resultFlowPath.installerId().toString());
+ assertEquals(paramFlow.flowPathFlags().flags(), resultFlowPath.flowPathFlags().flags());
assertEquals(paramFlow.dataPath().toString(), resultFlowPath.dataPath().toString());
assertEquals(paramFlow.flowEntryMatch().toString(), resultFlowPath.flowEntryMatch().toString());
}
@@ -608,9 +621,9 @@
FlowManager fm = createPartialMockAndInvokeDefaultConstructor(FlowManager.class, addFlow);
// instantiate required objects
- FlowPath flow1 = createTestFlowPath(1, "installer id", 1, 2, 3, 4);
- FlowPath flow2 = createTestFlowPath(2, "installer id", 2, 3, 4, 5);
- FlowPath flow3 = createTestFlowPath(3, "installer id", 3, 4, 5, 6);
+ FlowPath flow1 = createTestFlowPath(1, "installer id", 0, 1, 2, 3, 4);
+ FlowPath flow2 = createTestFlowPath(2, "installer id", 0, 2, 3, 4, 5);
+ FlowPath flow3 = createTestFlowPath(3, "installer id", 0, 3, 4, 5, 6);
Map<Long, Object> shortestPathMap = new HashMap<Long, Object>();
// setup expectations
@@ -675,7 +688,7 @@
mockStaticPartial(System.class, "nanoTime");
// instantiate required objects
- FlowPath flow1 = createTestFlowPath(1, "installer id", 1, 2, 3, 4);
+ FlowPath flow1 = createTestFlowPath(1, "installer id", 0, 1, 2, 3, 4);
Map<Long, Object> shortestPathMap = new HashMap<Long, Object>();
// setup expectations
@@ -718,7 +731,7 @@
FlowManager fm = createPartialMockAndInvokeDefaultConstructor(FlowManager.class, addFlow);
// instantiate required objects
- FlowPath flow1 = createTestFlowPath(1, "installer id", 1, 2, 3, 4);
+ FlowPath flow1 = createTestFlowPath(1, "installer id", 0, 1, 2, 3, 4);
Map<Long, Object> shortestPathMap = new HashMap<Long, Object>();
// setup expectations
@@ -757,7 +770,7 @@
@Test
public final void testMeasurementClearAllPathsSuccessNormally() throws Exception {
// instantiate required objects
- FlowPath paramFlow = createTestFlowPath(100, "installer id", 1, 3, 2, 4);
+ FlowPath paramFlow = createTestFlowPath(100, "installer id", 0, 1, 3, 2, 4);
Map<Long, Object> shortestPathMap = new HashMap<Long, Object>();
FlowManager fm = new FlowManager();
@@ -980,7 +993,7 @@
@Test
public final void testClearFlowSuccessNormally() throws Exception {
// create mock objects
- IFlowPath flowPath = createIFlowPathMock(123, "id", 1, 2, 3, 4);
+ IFlowPath flowPath = createIFlowPathMock(123, "id", 0, 1, 2, 3, 4);
IFlowEntry flowEntry1 = createMock(IFlowEntry.class);
IFlowEntry flowEntry2 = createMock(IFlowEntry.class);
IFlowEntry flowEntry3 = createMock(IFlowEntry.class);
@@ -1023,8 +1036,8 @@
@Test
public final void testGetAllFlowsWithoutFlowEntriesSuccessNormally() throws Exception {
// create mock objects
- IFlowPath iFlowPath1 = createIFlowPathMock(1, "caller id", 1, 1, 2, 2);
- IFlowPath iFlowPath2 = createIFlowPathMock(2, "caller id", 2, 5, 3, 5);
+ IFlowPath iFlowPath1 = createIFlowPathMock(1, "caller id", 0, 1, 1, 2, 2);
+ IFlowPath iFlowPath2 = createIFlowPathMock(2, "caller id", 0, 2, 5, 3, 5);
// instantiate required objects
ArrayList<IFlowPath> flowPaths = new ArrayList<IFlowPath>();
@@ -1060,7 +1073,7 @@
final String addFlowEntry = "addFlowEntry";
// create mock objects
- IFlowPath iFlowPath1 = createIFlowPathMock(1, "caller id", 1, 1, 2, 2);
+ IFlowPath iFlowPath1 = createIFlowPathMock(1, "caller id", 0, 1, 1, 2, 2);
IFlowEntry iFlowEntry1 = createMock(IFlowEntry.class);
IFlowEntry iFlowEntry2 = createMock(IFlowEntry.class);
FlowManager fm = createPartialMockAndInvokeDefaultConstructor(FlowManager.class, addFlowEntry);
@@ -1127,7 +1140,7 @@
public final void testInstallFlowEntryWithIFlowPathSuccessNormally() throws Exception {
// create mock object
IOFSwitch iofSwitch = createNiceMock(IOFSwitch.class);
- IFlowPath iFlowPath = createIFlowPathMock(1, "id", 1, 2, 3, 4);
+ IFlowPath iFlowPath = createIFlowPathMock(1, "id", 0, 1, 2, 3, 4);
IFlowEntry iFlowEntry = createMock(IFlowEntry.class);
BasicFactory basicFactory = createMock(BasicFactory.class);
diff --git a/src/test/java/net/onrc/onos/ofcontroller/routing/TopoRouteServiceTest.java b/src/test/java/net/onrc/onos/ofcontroller/routing/TopoRouteServiceTest.java
index e6d7d16..ba23a01 100644
--- a/src/test/java/net/onrc/onos/ofcontroller/routing/TopoRouteServiceTest.java
+++ b/src/test/java/net/onrc/onos/ofcontroller/routing/TopoRouteServiceTest.java
@@ -41,6 +41,7 @@
import net.onrc.onos.ofcontroller.routing.TopoRouteService;
import net.onrc.onos.ofcontroller.util.DataPath;
import net.onrc.onos.ofcontroller.util.Dpid;
+import net.onrc.onos.ofcontroller.util.FlowPathFlags;
import net.onrc.onos.ofcontroller.util.Port;
import net.onrc.onos.ofcontroller.util.SwitchPort;
@@ -132,6 +133,20 @@
String expectedResult = "1/00:00:00:00:00:00:0a:01/2;1/00:00:00:00:00:00:0a:03/2;2/00:00:00:00:00:00:0a:04/3;1/00:00:00:00:00:00:0a:06/1;";
assertEquals(dataPathSummaryStr, expectedResult);
+ // Test if we apply various Flow Path Flags
+ String expectedResult2 = "1/00:00:00:00:00:00:0a:03/2;2/00:00:00:00:00:00:0a:04/3;1/00:00:00:00:00:00:0a:06/1;";
+ String expectedResult3 = "1/00:00:00:00:00:00:0a:03/2;";
+ FlowPathFlags flowPathFlags2 = new FlowPathFlags("DISCARD_FIRST_HOP_ENTRY");
+ FlowPathFlags flowPathFlags3 = new FlowPathFlags("KEEP_ONLY_FIRST_HOP_ENTRY");
+ //
+ dataPath.applyFlowPathFlags(flowPathFlags2);
+ dataPathSummaryStr = dataPath.dataPathSummary();
+ assertEquals(dataPathSummaryStr, expectedResult2);
+ //
+ dataPath.applyFlowPathFlags(flowPathFlags3);
+ dataPathSummaryStr = dataPath.dataPathSummary();
+ assertEquals(dataPathSummaryStr, expectedResult3);
+
//
// Test Shortest-Path computation to non-existing destination
//
@@ -180,6 +195,20 @@
String expectedResult = "1/00:00:00:00:00:00:0a:01/2;1/00:00:00:00:00:00:0a:03/2;2/00:00:00:00:00:00:0a:04/3;1/00:00:00:00:00:00:0a:06/1;";
assertEquals(dataPathSummaryStr, expectedResult);
+ // Test if we apply various Flow Path Flags
+ String expectedResult2 = "1/00:00:00:00:00:00:0a:03/2;2/00:00:00:00:00:00:0a:04/3;1/00:00:00:00:00:00:0a:06/1;";
+ String expectedResult3 = "1/00:00:00:00:00:00:0a:03/2;";
+ FlowPathFlags flowPathFlags2 = new FlowPathFlags("DISCARD_FIRST_HOP_ENTRY");
+ FlowPathFlags flowPathFlags3 = new FlowPathFlags("KEEP_ONLY_FIRST_HOP_ENTRY");
+ //
+ dataPath.applyFlowPathFlags(flowPathFlags2);
+ dataPathSummaryStr = dataPath.dataPathSummary();
+ assertEquals(dataPathSummaryStr, expectedResult2);
+ //
+ dataPath.applyFlowPathFlags(flowPathFlags3);
+ dataPathSummaryStr = dataPath.dataPathSummary();
+ assertEquals(dataPathSummaryStr, expectedResult3);
+
//
// Test Shortest-Path computation to non-existing destination
//