ONOS-2003 Fixing intent reroute after cluster change

Objective trackers update when partitions are shuffled to
track "local" intents.

Change-Id: I7cd9e4a935ddbc94813d5067d4febc084a89f508
diff --git a/core/api/src/main/java/org/onosproject/cluster/LeadershipEventListener.java b/core/api/src/main/java/org/onosproject/cluster/LeadershipEventListener.java
index 20f2c24..53d84b1 100644
--- a/core/api/src/main/java/org/onosproject/cluster/LeadershipEventListener.java
+++ b/core/api/src/main/java/org/onosproject/cluster/LeadershipEventListener.java
@@ -20,5 +20,5 @@
 /**
  * Entity capable of receiving device leadership-related events.
  */
-public interface LeadershipEventListener  extends EventListener<LeadershipEvent> {
+public interface LeadershipEventListener extends EventListener<LeadershipEvent> {
 }
diff --git a/core/api/src/main/java/org/onosproject/net/intent/PartitionEvent.java b/core/api/src/main/java/org/onosproject/net/intent/PartitionEvent.java
new file mode 100644
index 0000000..48623dd
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/intent/PartitionEvent.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.intent;
+
+import org.onosproject.event.AbstractEvent;
+
+/**
+ * Partition event.
+ */
+//TODO change String into a proper object type
+public class PartitionEvent extends AbstractEvent<PartitionEvent.Type, String> {
+
+    public enum Type {
+        LEADER_CHANGED
+    }
+
+    public PartitionEvent(Type type, String partition) {
+        super(type, partition);
+    }
+}
diff --git a/core/api/src/main/java/org/onosproject/net/intent/PartitionEventListener.java b/core/api/src/main/java/org/onosproject/net/intent/PartitionEventListener.java
new file mode 100644
index 0000000..73b9de9
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/intent/PartitionEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.intent;
+
+import org.onosproject.event.EventListener;
+
+/**
+ * Entity capable of receiving device partition-related events.
+ */
+public interface PartitionEventListener extends EventListener<PartitionEvent> {
+}
diff --git a/core/api/src/main/java/org/onosproject/net/intent/PartitionService.java b/core/api/src/main/java/org/onosproject/net/intent/PartitionService.java
index e963abc..c636cd2 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/PartitionService.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/PartitionService.java
@@ -40,4 +40,18 @@
     NodeId getLeader(Key intentKey);
 
     // TODO add API for rebalancing partitions
+
+    /**
+     * Registers a event listener to be notified of partition events.
+     *
+     * @param listener listener that will asynchronously notified of partition events.
+     */
+    void addListener(PartitionEventListener listener);
+
+    /**
+     * Unregisters a event listener for partition events.
+     *
+     * @param listener listener to be removed.
+     */
+    void removeListener(PartitionEventListener listener);
 }