Added WITHDRAW_REQ Intent State for ONOS-146

Fixed flow removed from other instance

Change-Id: I22c88a447e26770fea8b7e23f4a78b1389077ad1
diff --git a/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java b/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java
index b175535..168f044 100644
--- a/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java
+++ b/core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java
@@ -176,7 +176,6 @@
         if (obj instanceof DefaultFlowRule) {
             DefaultFlowRule that = (DefaultFlowRule) obj;
             return Objects.equals(deviceId, that.deviceId) &&
-                    Objects.equals(id, that.id) &&
                     Objects.equals(priority, that.priority) &&
                     Objects.equals(selector, that.selector);
 
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/IntentEvent.java b/core/api/src/main/java/org/onlab/onos/net/intent/IntentEvent.java
index 495f3ea..37261e9 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/IntentEvent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/IntentEvent.java
@@ -24,9 +24,9 @@
 
     public enum Type {
         /**
-         * Signifies that a new intent has been submitted to the system.
+         * Signifies that an intent is to be installed or reinstalled.
          */
-        SUBMITTED,
+        INSTALL_REQ,
 
         /**
          * Signifies that an intent has been successfully installed.
@@ -39,6 +39,11 @@
         FAILED,
 
         /**
+         * Signifies that an intent will be withdrawn.
+         */
+        WITHDRAW_REQ,
+
+        /**
          * Signifies that an intent has been withdrawn from the system.
          */
         WITHDRAWN
@@ -70,12 +75,15 @@
     public static IntentEvent getEvent(IntentState state, Intent intent) {
         Type type;
         switch (state) {
-            case SUBMITTED:
-                type = Type.SUBMITTED;
+            case INSTALL_REQ:
+                type = Type.INSTALL_REQ;
                 break;
             case INSTALLED:
                 type = Type.INSTALLED;
                 break;
+            case WITHDRAW_REQ:
+                type = Type.WITHDRAW_REQ;
+                break;
             case WITHDRAWN:
                 type = Type.WITHDRAWN;
                 break;
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/IntentState.java b/core/api/src/main/java/org/onlab/onos/net/intent/IntentState.java
index 0e9211d..4a534c1 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/IntentState.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/IntentState.java
@@ -26,9 +26,11 @@
      * local controller instance.
      * <p>
      * All intent in the runtime take this state first.
+     * </p><p>
+     * Intents will also pass through this state when they are updated.
      * </p>
      */
-    SUBMITTED,
+    INSTALL_REQ,
 
     /**
      * Signifies that the intent is being compiled into installable intents.
@@ -67,16 +69,11 @@
     RECOMPILING,
 
     /**
-     * TODO: Indicated that an intent will soon be recompiled.
-     */
-    //UPDATE,
-
-    /**
-     * TODO.
      * Indicates that an application has requested that an intent be withdrawn.
-     * It will start withdrawing short, but not necessarily on this instance.
+     * It will start withdrawing shortly, but not necessarily on this instance.
+     * Intents can also be parked here if it is impossible to withdraw them.
      */
-    //WITHDRAW_REQ,
+    WITHDRAW_REQ,
 
     /**
      * Indicates that the intent is being withdrawn. This is a transitional
diff --git a/core/api/src/test/java/org/onlab/onos/net/intent/FakeIntentManager.java b/core/api/src/test/java/org/onlab/onos/net/intent/FakeIntentManager.java
index d6732c7..7074a5c 100644
--- a/core/api/src/test/java/org/onlab/onos/net/intent/FakeIntentManager.java
+++ b/core/api/src/test/java/org/onlab/onos/net/intent/FakeIntentManager.java
@@ -174,8 +174,8 @@
     @Override
     public void submit(Intent intent) {
         intents.put(intent.id(), intent);
-        setState(intent, IntentState.SUBMITTED);
-        dispatch(new IntentEvent(IntentEvent.Type.SUBMITTED, intent));
+        setState(intent, IntentState.INSTALL_REQ);
+        dispatch(new IntentEvent(IntentEvent.Type.INSTALL_REQ, intent));
         executeSubmit(intent);
     }
 
diff --git a/core/api/src/test/java/org/onlab/onos/net/intent/IntentServiceTest.java b/core/api/src/test/java/org/onlab/onos/net/intent/IntentServiceTest.java
index 6a3197d..acbfb3d 100644
--- a/core/api/src/test/java/org/onlab/onos/net/intent/IntentServiceTest.java
+++ b/core/api/src/test/java/org/onlab/onos/net/intent/IntentServiceTest.java
@@ -21,7 +21,7 @@
 import static org.junit.Assert.fail;
 import static org.onlab.onos.net.intent.IntentEvent.Type.FAILED;
 import static org.onlab.onos.net.intent.IntentEvent.Type.INSTALLED;
-import static org.onlab.onos.net.intent.IntentEvent.Type.SUBMITTED;
+import static org.onlab.onos.net.intent.IntentEvent.Type.INSTALL_REQ;
 import static org.onlab.onos.net.intent.IntentEvent.Type.WITHDRAWN;
 
 import java.util.ArrayList;
@@ -96,7 +96,7 @@
         });
 
         // Make sure that all expected events have been emitted
-        validateEvents(intent, SUBMITTED, INSTALLED);
+        validateEvents(intent, INSTALL_REQ, INSTALLED);
 
         // Make sure there is just one intent (and is ours)
         assertEquals("incorrect intent count", 1, service.getIntentCount());
@@ -145,7 +145,7 @@
         });
 
         // Make sure that all expected events have been emitted
-        validateEvents(intent, SUBMITTED, FAILED);
+        validateEvents(intent, INSTALL_REQ, FAILED);
     }
 
     @Test
@@ -168,7 +168,7 @@
         });
 
         // Make sure that all expected events have been emitted
-        validateEvents(intent, SUBMITTED, FAILED);
+        validateEvents(intent, INSTALL_REQ, FAILED);
     }
 
     /**