Add interfaces for FlowMap and FlowBatchMap.
- These interfacees are used by FlowManagerModule and are not exposed to applications.
- This task is preperation for ONOS-1688, ONOS-1736 and ONOS-1842.
Change-Id: I93c7e9fc30ad0c0eb1c1879660416e59057ec123
diff --git a/src/main/java/net/onrc/onos/core/flowmanager/FlowBatchMap.java b/src/main/java/net/onrc/onos/core/flowmanager/FlowBatchMap.java
new file mode 100644
index 0000000..6886d68
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/flowmanager/FlowBatchMap.java
@@ -0,0 +1,92 @@
+package net.onrc.onos.core.flowmanager;
+
+import java.util.Set;
+
+import net.onrc.onos.api.flowmanager.FlowBatchId;
+import net.onrc.onos.api.flowmanager.FlowBatchOperation;
+import net.onrc.onos.api.flowmanager.FlowBatchState;
+
+/**
+ * Interface of the flow batch map.
+ */
+interface FlowBatchMap {
+ /**
+ * Gets {@link FlowBatchOperation} object having {@link FlowBatchId} as its
+ * ID from the map.
+ *
+ * @param id the {@link FlowBatchId} to be used for getting the object
+ * @return {@link FlowBatchOperation} object if exists, null otherwise
+ */
+ FlowBatchOperation get(FlowBatchId id);
+
+ /**
+ * Puts {@link FlowBatchOperation} object to the map.
+ *
+ * @param id the {@link FlowBatchId} to be used for the object
+ * @param flowOp the {@link FlowBatchOperation} object
+ * @return true if the object was successfully added
+ */
+ boolean put(FlowBatchId id, FlowBatchOperation flowOp);
+
+ /**
+ * Removes {@link FlowBatchOperation} object from the map.
+ *
+ * @param id the {@link FlowBatchId} to be used for removing the object
+ * @return the removed {@link FlowBatchOperation} object if exists, null
+ * otherwise
+ */
+ FlowBatchOperation remove(FlowBatchId id);
+
+ /**
+ * Gets all {@link FlowBatchOperation} objects existing in the map.
+ * <p>
+ * The changes to the returned set does not affect the original map.
+
+ * @return a set of {@link FlowBatchOperation} objects
+ */
+ Set<FlowBatchOperation> getAll();
+
+ /**
+ * Sets {@link FlowBatchState} to the specified {@link FlowBatchOperation}
+ * object.
+ *
+ * @param id the {@link FlowBatchId} of the {@link FlowBatchOperation}
+ * @param state the {@link FlowBatchState} to be set
+ * @param expectedState the {@link FlowBatchState} expected as the previous
+ * state
+ * @return true if the ID existed, the previous state was the expected state
+ * and successfully updated the state
+ */
+ boolean setState(FlowBatchId id, FlowBatchState state, FlowBatchState expectedState);
+
+ /**
+ * Gets {@link FlowBatchState} of the specified {@link FlowBatchOperation}
+ * object.
+ *
+ * @param id the {@link FlowBatchId} of the {@link FlowBatchOperation}
+ * @return the {@link FlowBatchState} of the {@link FlowBatchOperation} or
+ * null if the object does not exist
+ */
+ FlowBatchState getState(FlowBatchId id);
+
+ /**
+ * Adds a listener for listening events related to the map.
+ *
+ * @param listener the {@link FlowBatchMapEventListener} to be added
+ */
+ void addListener(FlowBatchMapEventListener listener);
+
+ /**
+ * Removes a listener for listening events related to the map.
+ *
+ * @param listener the {@link FlowBatchMapEventListener} to be removed
+ */
+ void removeListener(FlowBatchMapEventListener listener);
+
+ /**
+ * Checks if this instance is a leader of the map.
+ *
+ * @return true if it is leader, false otherwise
+ */
+ boolean isLeader();
+}
diff --git a/src/main/java/net/onrc/onos/core/flowmanager/FlowBatchMapEventListener.java b/src/main/java/net/onrc/onos/core/flowmanager/FlowBatchMapEventListener.java
new file mode 100644
index 0000000..93a0bdf
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/flowmanager/FlowBatchMapEventListener.java
@@ -0,0 +1,34 @@
+package net.onrc.onos.core.flowmanager;
+
+import net.onrc.onos.api.flowmanager.FlowBatchId;
+import net.onrc.onos.api.flowmanager.FlowBatchOperation;
+import net.onrc.onos.api.flowmanager.FlowBatchState;
+
+interface FlowBatchMapEventListener {
+ /**
+ * Invoked when a {@link FlowBatchOperation} object is added.
+ *
+ * @param id the ID of the {@link FlowBatchOperation}.
+ * @param flowOp the {@link FlowBatchOperation} object.
+ */
+ void flowBatchOperationAdded(FlowBatchId id, FlowBatchOperation flowOp);
+
+ /**
+ * Invoked when a {@link FlowBatchOperation} object is removed.
+ *
+ * @param id the ID of the {@link FlowBatchOperation}.
+ */
+ void flowBatchOperationRemoved(FlowBatchId id);
+
+ /**
+ * Invoked when a {@link FlowBatchState} of a {@link FlowBatchOperation}
+ * object is changed.
+ *
+ * @param id the ID of the {@link FlowBatchOperation}
+ * @param oldState the old state of the {@link FlowBatchOperation}
+ * @param currentState the current state of the {@link FlowBatchOperation}
+ */
+ void flowStateChanged(FlowBatchId id,
+ FlowBatchState oldState, FlowBatchState currentState);
+
+}
diff --git a/src/main/java/net/onrc/onos/core/flowmanager/FlowMap.java b/src/main/java/net/onrc/onos/core/flowmanager/FlowMap.java
new file mode 100644
index 0000000..edd6ab5
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/flowmanager/FlowMap.java
@@ -0,0 +1,79 @@
+package net.onrc.onos.core.flowmanager;
+
+import java.util.Set;
+
+import net.onrc.onos.api.flowmanager.Flow;
+import net.onrc.onos.api.flowmanager.FlowId;
+import net.onrc.onos.api.flowmanager.FlowState;
+
+/**
+ * Interface of the flow map.
+ */
+interface FlowMap {
+ /**
+ * Gets {@link Flow} object having {@link FlowId} as its ID from the map.
+ *
+ * @param id the {@link FlowId} to be used for getting the object
+ * @return {@link Flow} object if exists, null otherwise
+ */
+ Flow get(FlowId id);
+
+ /**
+ * Puts {@link Flow} object to the map.
+ *
+ * @param flow the {@link Flow} object
+ * @return true if the object was successfully added
+ */
+ boolean put(Flow flow);
+
+ /**
+ * Removes {@link Flow} object from the map.
+ *
+ * @param id the {@link FlowId} to be used for removing the object
+ * @return the removed {@link Flow} object if exists, null otherwise
+ */
+ Flow remove(FlowId id);
+
+ /**
+ * Gets all {@link Flow} objects existing in the map.
+ * <p>
+ * The changes to the returned set does not affect the original map.
+ *
+ * @return a set of {@link Flow} objects
+ */
+ Set<Flow> getAll();
+
+ /**
+ * Sets {@link FlowState} to the specified {@link Flow} object.
+ *
+ * @param id the {@link FlowId} of the {@link Flow}
+ * @param state the {@link FlowState} to be set
+ * @param expectedState the {@link FlowState} expected as the previous state
+ * @return true if the ID existed, the previous state was the expected state
+ * and successfully updated the state
+ */
+ boolean setState(FlowId id, FlowState state, FlowState expectedState);
+
+ /**
+ * Gets {@link FlowState} of the specified {@link Flow} object.
+ *
+ * @param id the {@link FlowId} of the {@link Flow}
+ * @return the {@link FlowState} of the {@link Flow} or null if the
+ * {@link Flow} does not exist
+ */
+ FlowState getState(FlowId id);
+
+ /**
+ * Adds a listener for listening events related to the map.
+ *
+ * @param listener the {@link FlowMapEventListener} to be added
+ */
+ void addListener(FlowMapEventListener listener);
+
+ /**
+ * Removes a listener for listening events related to the map.
+ *
+ * @param listener the {@link FlowMapEventListener} to be removed
+ */
+ void removeListener(FlowMapEventListener listener);
+}
diff --git a/src/main/java/net/onrc/onos/core/flowmanager/FlowMapEventListener.java b/src/main/java/net/onrc/onos/core/flowmanager/FlowMapEventListener.java
new file mode 100644
index 0000000..adc8225
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/flowmanager/FlowMapEventListener.java
@@ -0,0 +1,34 @@
+package net.onrc.onos.core.flowmanager;
+
+import net.onrc.onos.api.flowmanager.Flow;
+import net.onrc.onos.api.flowmanager.FlowId;
+import net.onrc.onos.api.flowmanager.FlowState;
+
+/**
+ * An interface to the event listener of the flow map.
+ */
+interface FlowMapEventListener {
+ /**
+ * Invoked when a {@link Flow} object is added.
+ *
+ * @param id the ID of the {@link Flow}.
+ * @param flow the {@link Flow} object.
+ */
+ void flowAdded(FlowId id, Flow flow);
+
+ /**
+ * Invoked when a {@link Flow} object is removed.
+ *
+ * @param id the ID of the {@link Flow}.
+ */
+ void flowRemoved(FlowId id);
+
+ /**
+ * Invoked when a {@link FlowState} of a {@link Flow} object is changed.
+ *
+ * @param id the ID of the {@link Flow}
+ * @param oldState the old state of the {@link Flow}
+ * @param currentState the current state of the {@link Flow}
+ */
+ void flowStateChanged(FlowId id, FlowState oldState, FlowState currentState);
+}