Merge "Add log rotation for each Intent state change log and fix rerouting bug" into dev/ramcloud-new-datamodel
diff --git a/src/main/java/net/onrc/onos/intent/Intent.java b/src/main/java/net/onrc/onos/intent/Intent.java
index b6a51cb..c6a960f 100644
--- a/src/main/java/net/onrc/onos/intent/Intent.java
+++ b/src/main/java/net/onrc/onos/intent/Intent.java
@@ -54,6 +54,9 @@
 	public IntentState setState(IntentState newState) {
 		logs.add(String.format("setState, oldState:%s, newState:%s, time:%d",
 				state, newState, System.nanoTime())); // for measurement
+		if (logs.size() > 20) { // TODO this size should be configurable
+			logs.removeFirst();
+		}
 		IntentState oldState = state;
 		state = newState;
 		return oldState;
diff --git a/src/main/java/net/onrc/onos/intent/runtime/PathCalcRuntime.java b/src/main/java/net/onrc/onos/intent/runtime/PathCalcRuntime.java
index abd68d1..6ff92db 100644
--- a/src/main/java/net/onrc/onos/intent/runtime/PathCalcRuntime.java
+++ b/src/main/java/net/onrc/onos/intent/runtime/PathCalcRuntime.java
@@ -107,19 +107,6 @@
 					pathIntentOpList.add(Operator.REMOVE, new Intent(oldPathIntentId));
 				}
 
-				// remove old path-intent if exists
-				Intent oldIntent = appIntents.getIntent(spIntent.getId());
-				if (oldIntent != null) {
-					ShortestPathIntent oldSpIntent = (ShortestPathIntent)oldIntent;
-					String pathIntentId = oldSpIntent.getPathIntentId();
-					if (pathIntentId != null) {
-						Intent targetPathIntent = pathIntents.getIntent(pathIntentId);
-						if (targetPathIntent != null) {
-							pathIntentOpList.add(Operator.REMOVE, targetPathIntent);
-						}
-					}
-				}
-
 				// create new path-intent
 				PathIntent pathIntent = new PathIntent(newPathIntentId, path, bandwidth, spIntent);
 				pathIntent.setState(IntentState.INST_REQ);