* Added a class for encapsulating events with event-related data entry.
* Use the above class within the FlowManager to store the initial set
of Flow-related events during startup.
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
index 5a4edc3..012f333 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
@@ -7,7 +7,9 @@
import java.util.LinkedList;
import java.util.Map;
import java.util.Random;
+import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@@ -70,6 +72,10 @@
private ScheduledExecutorService mapReaderScheduler;
private ScheduledExecutorService shortestPathReconcileScheduler;
+ // The queue with Flow Path updates
+ protected BlockingQueue<EventEntry<FlowPath>> flowPathEvents =
+ new LinkedBlockingQueue<EventEntry<FlowPath>>();
+
/**
* Periodic task for reading the Flow Entries and pushing changes
* into the switches.
@@ -488,10 +494,16 @@
// Initialize the Flow Entry ID generator
nextFlowEntryIdPrefix = randomGenerator.nextInt();
+ // Register with the Datagrid Service and obtain the initial state
datagridService.registerFlowService(this);
- // TODO: Flow Paths not used yet
Collection<FlowPath> flowPaths = datagridService.getAllFlows();
+ for (FlowPath flowPath : flowPaths) {
+ EventEntry<FlowPath> eventEntry =
+ new EventEntry<FlowPath>(EventEntry.Type.ENTRY_ADD, flowPath);
+ flowPathEvents.add(eventEntry);
+ }
+ // Schedule the periodic tasks
mapReaderScheduler.scheduleAtFixedRate(
mapReader, 3, 3, TimeUnit.SECONDS);
shortestPathReconcileScheduler.scheduleAtFixedRate(
diff --git a/src/main/java/net/onrc/onos/ofcontroller/util/EventEntry.java b/src/main/java/net/onrc/onos/ofcontroller/util/EventEntry.java
new file mode 100644
index 0000000..638c9a8
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/util/EventEntry.java
@@ -0,0 +1,46 @@
+package net.onrc.onos.ofcontroller.util;
+
+/**
+ * Class for encapsulating events with event-related data entry.
+ */
+public class EventEntry<T> {
+ /**
+ * The event types.
+ */
+ public enum Type {
+ ENTRY_ADD, // Add or update an entry
+ ENTRY_REMOVE // Remove an entry
+ }
+
+ private Type eventType; // The event type
+ private T eventData; // The relevant event data entry
+
+ /**
+ * Constructor for a given event type and event-related data entry.
+ *
+ * @param eventType the event type.
+ * @param eventData the event data entry.
+ */
+ public EventEntry(EventEntry.Type eventType, T eventData) {
+ this.eventType = eventType;
+ this.eventData = eventData;
+ }
+
+ /**
+ * Test whether the event type is ENTRY_ADD.
+ *
+ * @return true if the event type is ENTRY_ADD, otherwise false.
+ */
+ public boolean isAdd() {
+ return (this.eventType == Type.ENTRY_ADD);
+ }
+
+ /**
+ * Test whether the event type is ENTRY_REMOVE.
+ *
+ * @return true if the event type is ENTRY_REMOVE, otherwise false.
+ */
+ public boolean isRemove() {
+ return (this.eventType == Type.ENTRY_REMOVE);
+ }
+}