Update rerouting features
- add REROUTE_REQ state to Intent class
- add static methods to PathIntent class to create IDs
- add getPathIntentId() to ShortestPathIntent class to retrieve low-level intent
- add mapping of inserting or replacing high level ids to lower level ids.
- change high level intent state to REROUTE_REQ if the state was INST_ACK and the intent was requested rerouting
Change-Id: I50970a0255e2b19451aaedb7dc3c19015031e5d0
diff --git a/src/test/java/net/onrc/onos/intent/PathIntentTest.java b/src/test/java/net/onrc/onos/intent/PathIntentTest.java
index a465118..3c76f3f 100644
--- a/src/test/java/net/onrc/onos/intent/PathIntentTest.java
+++ b/src/test/java/net/onrc/onos/intent/PathIntentTest.java
@@ -29,6 +29,18 @@
}
@Test
+ public void testCreateFirstId() {
+ String id = PathIntent.createFirstId("100");
+ assertEquals("pi100___0", id);
+ }
+
+ @Test
+ public void testCreateNextId() {
+ String id = PathIntent.createNextId("pi100___999");
+ assertEquals("pi100___1000", id);
+ }
+
+ @Test
public void test() {
KryoFactory factory = new KryoFactory();
Kryo kryo = factory.newKryo();
diff --git a/src/test/java/net/onrc/onos/intent/runtime/UseCaseTest.java b/src/test/java/net/onrc/onos/intent/runtime/UseCaseTest.java
index 698f790..00da877 100755
--- a/src/test/java/net/onrc/onos/intent/runtime/UseCaseTest.java
+++ b/src/test/java/net/onrc/onos/intent/runtime/UseCaseTest.java
@@ -1,5 +1,6 @@
package net.onrc.onos.intent.runtime;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@@ -11,7 +12,9 @@
import net.onrc.onos.intent.ConstrainedShortestPathIntent;
import net.onrc.onos.intent.FlowEntry;
import net.onrc.onos.intent.Intent;
+import net.onrc.onos.intent.Intent.IntentState;
import net.onrc.onos.intent.IntentOperation.Operator;
+import net.onrc.onos.intent.IntentOperation;
import net.onrc.onos.intent.IntentOperationList;
import net.onrc.onos.intent.MockNetworkGraph;
import net.onrc.onos.intent.PathIntent;
@@ -217,25 +220,21 @@
showResult((PathIntentMap) runtime1.getPathIntents());
System.out.println(plan);
+ // TODO this state changes should be triggered by notification of plan module
+ HashMap<String, IntentState> states = new HashMap<>();
+ states.put("1", IntentState.INST_ACK);
+ states.put("2", IntentState.INST_ACK);
+ states.put("3", IntentState.INST_ACK);
+ runtime1.getHighLevelIntents().changeStates(states);
+
// link down
((MockNetworkGraph)g).removeLink(1L, 2L, 9L, 1L); // This link is used by the intent "1"
- LinkEvent linkEvent = new LinkEvent(1L, 2L, 9L, 1L);
- removedLinkEvents.clear();
- removedLinkEvents.add(linkEvent);
- runtime1.networkGraphEvents(
- addedSwitchEvents,
- removedSwitchEvents,
- addedPortEvents,
- removedPortEvents,
- addedLinkEvents,
- removedLinkEvents,
- addedDeviceEvents,
- removedDeviceEvents);
-
((MockNetworkGraph)g).removeLink(9L, 1L, 1L, 2L);
- linkEvent = new LinkEvent(9L, 1L, 1L, 2L);
+ LinkEvent linkEvent1 = new LinkEvent(1L, 2L, 9L, 1L);
+ LinkEvent linkEvent2 = new LinkEvent(9L, 1L, 1L, 2L);
removedLinkEvents.clear();
- removedLinkEvents.add(linkEvent);
+ removedLinkEvents.add(linkEvent1);
+ removedLinkEvents.add(linkEvent2);
runtime1.networkGraphEvents(
addedSwitchEvents,
removedSwitchEvents,