Added new API to the IDatagridService to get/lookup a Flow or a Flow Entry
for a given Flow ID or Flow Entry ID respectively. Implement
the API for Hazelcast:
* getFlow(FlowId flowId)
* getFlowEntry(FlowEntryId flowEntryId)
diff --git a/src/main/java/net/onrc/onos/datagrid/HazelcastDatagrid.java b/src/main/java/net/onrc/onos/datagrid/HazelcastDatagrid.java
index 180cbe9..775f952 100644
--- a/src/main/java/net/onrc/onos/datagrid/HazelcastDatagrid.java
+++ b/src/main/java/net/onrc/onos/datagrid/HazelcastDatagrid.java
@@ -607,6 +607,29 @@
}
/**
+ * Get a Flow for a given Flow ID.
+ *
+ * @param flowId the Flow ID of the Flow to get.
+ * @return the Flow if found, otherwise null.
+ */
+ @Override
+ public FlowPath getFlow(FlowId flowId) {
+ byte[] valueBytes = mapFlow.get(flowId.value());
+ if (valueBytes == null)
+ return null;
+
+ Kryo kryo = kryoFactory.newKryo();
+ //
+ // Decode the value
+ //
+ Input input = new Input(valueBytes);
+ FlowPath flowPath = kryo.readObject(input, FlowPath.class);
+ kryoFactory.deleteKryo(kryo);
+
+ return flowPath;
+ }
+
+ /**
* Send a notification that a Flow is added.
*
* @param flowPath the Flow that is added.
@@ -702,6 +725,29 @@
}
/**
+ * Get a Flow Entry for a given Flow Entry ID.
+ *
+ * @param flowEntryId the Flow Entry ID of the Flow Entry to get.
+ * @return the Flow Entry if found, otherwise null.
+ */
+ @Override
+ public FlowEntry getFlowEntry(FlowEntryId flowEntryId) {
+ byte[] valueBytes = mapFlowEntry.get(flowEntryId.value());
+ if (valueBytes == null)
+ return null;
+
+ Kryo kryo = kryoFactory.newKryo();
+ //
+ // Decode the value
+ //
+ Input input = new Input(valueBytes);
+ FlowEntry flowEntry = kryo.readObject(input, FlowEntry.class);
+ kryoFactory.deleteKryo(kryo);
+
+ return flowEntry;
+ }
+
+ /**
* Send a notification that a FlowEntry is added.
*
* @param flowEntry the FlowEntry that is added.
diff --git a/src/main/java/net/onrc/onos/datagrid/IDatagridService.java b/src/main/java/net/onrc/onos/datagrid/IDatagridService.java
index 9361341..034fe25 100644
--- a/src/main/java/net/onrc/onos/datagrid/IDatagridService.java
+++ b/src/main/java/net/onrc/onos/datagrid/IDatagridService.java
@@ -50,7 +50,7 @@
* @param arpEventHandler The ARP event handler to de-register.
*/
public void deregisterArpEventHandler(IArpEventHandler arpEventHandler);
-
+
/**
* Get all Flows that are currently in the datagrid.
*
@@ -59,6 +59,14 @@
Collection<FlowPath> getAllFlows();
/**
+ * Get a Flow for a given Flow ID.
+ *
+ * @param flowId the Flow ID of the Flow to get.
+ * @return the Flow if found, otherwise null.
+ */
+ FlowPath getFlow(FlowId flowId);
+
+ /**
* Send a notification that a Flow is added.
*
* @param flowPath the Flow that is added.
@@ -92,6 +100,14 @@
Collection<FlowEntry> getAllFlowEntries();
/**
+ * Get a Flow Entry for a given Flow Entry ID.
+ *
+ * @param flowEntryId the Flow Entry ID of the Flow Entry to get.
+ * @return the Flow Entry if found, otherwise null.
+ */
+ FlowEntry getFlowEntry(FlowEntryId flowEntryId);
+
+ /**
* Send a notification that a FlowEntry is added.
*
* @param flowEntry the FlowEntry that is added.