Fix incorrect state of Intent after re-installed from FAILED state.

Avoid same IntentData resubmitted by multiple ONOS nodes.
Also, avoid same IntentData/IntentOperationContext modified by different
threds.

Change-Id: Ifb550c41204d6e86e379fd44c2787980920d2b9e
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/IntentManager.java b/core/net/src/main/java/org/onosproject/net/intent/impl/IntentManager.java
index 14d2bea..f94ad8c 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/IntentManager.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/IntentManager.java
@@ -460,6 +460,9 @@
                                        boolean compileAllFailed) {
         // Attempt recompilation of the specified intents first.
         for (Key key : intentKeys) {
+            if (!store.isMaster(key)) {
+                continue;
+            }
             Intent intent = store.getIntent(key);
             if (intent == null) {
                 continue;
@@ -470,6 +473,9 @@
         if (compileAllFailed) {
             // If required, compile all currently failed intents.
             for (Intent intent : getIntents()) {
+                if (!store.isMaster(intent.key())) {
+                    continue;
+                }
                 IntentState state = getIntentState(intent.key());
                 if (RECOMPILE.contains(state) || intentAllowsPartialFailure(intent)) {
                     if (WITHDRAW.contains(state)) {