add setFlowProperties() to DBOperation class
diff --git a/src/main/java/net/onrc/onos/graph/DBOperation.java b/src/main/java/net/onrc/onos/graph/DBOperation.java
index 0b91dd2..57ae599 100644
--- a/src/main/java/net/onrc/onos/graph/DBOperation.java
+++ b/src/main/java/net/onrc/onos/graph/DBOperation.java
@@ -5,12 +5,19 @@
package net.onrc.onos.graph;
import com.tinkerpop.blueprints.Vertex;
+import com.tinkerpop.blueprints.impls.ramcloud.*;
import com.tinkerpop.frames.FramedGraph;
import com.tinkerpop.frames.structures.FramedVertexIterable;
import com.tinkerpop.gremlin.java.GremlinPipeline;
+
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IBaseObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IDeviceObject;
@@ -20,6 +27,7 @@
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
import net.onrc.onos.ofcontroller.core.ISwitchStorage;
+import net.onrc.onos.ofcontroller.flowmanager.FlowDatabaseOperation;
import net.onrc.onos.ofcontroller.util.FlowEntryId;
import net.onrc.onos.ofcontroller.util.FlowId;
@@ -30,6 +38,8 @@
public abstract class DBOperation implements IDBOperation {
protected DBConnection conn;
+ private final static Logger log = LoggerFactory.getLogger(DBOperation.class);
+
/**
* Search and get an active switch object with DPID.
@@ -414,4 +424,12 @@
public void close() {
conn.close();
}
+
+ @Override
+ public void setFlowProperties(IFlowEntry flowEntry, Map<String, Object> map) {
+ log.debug("setProperties start: size {}", map.size());
+ RamCloudVertex v = (RamCloudVertex) flowEntry.asVertex();
+ v.setProperties(map);
+ log.debug("setProperties end: size {}, id {}", map.size(), v.getId());
+ }
}
diff --git a/src/main/java/net/onrc/onos/graph/IDBOperation.java b/src/main/java/net/onrc/onos/graph/IDBOperation.java
index f873f27..a2c6044 100644
--- a/src/main/java/net/onrc/onos/graph/IDBOperation.java
+++ b/src/main/java/net/onrc/onos/graph/IDBOperation.java
@@ -1,5 +1,7 @@
package net.onrc.onos.graph;
+import java.util.Map;
+
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IDeviceObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowEntry;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath;
@@ -39,7 +41,9 @@
public IFlowEntry searchFlowEntry(FlowEntryId flowEntryId);
public Iterable<IFlowEntry> getAllFlowEntries();
public void removeFlowEntry(IFlowEntry flowEntry);
-
+
+ public void setFlowProperties(IFlowEntry flowEntry, Map<String, Object> map);
+
public IDBConnection getDBConnection();
public void commit();
public void rollback();
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java
index b944a01..66d355e 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java
@@ -420,12 +420,15 @@
if (measureONOSFlowEntryTimeProp) {
startSetProperties = System.nanoTime();
}
+
+ FlowProperty flowProp = new FlowProperty(dbHandler, flowEntryObj);
+
//
// Set the Flow Entry key:
// - flowEntry.flowEntryId()
//
- flowEntryObj.setFlowEntryId(flowEntry.flowEntryId().toString());
- flowEntryObj.setType("flow_entry");
+ flowProp.setFlowEntryId(flowEntry.flowEntryId().toString());
+ flowProp.setType("flow_entry");
if (measureONOSFlowEntryTimeProp) {
numProperties += 2;
}
@@ -465,9 +468,9 @@
endSearchSwitch = System.nanoTime();
}
- flowEntryObj.setIdleTimeout(flowEntry.idleTimeout());
- flowEntryObj.setHardTimeout(flowEntry.hardTimeout());
- flowEntryObj.setSwitchDpid(flowEntry.dpid().toString());
+ flowProp.setIdleTimeout(flowEntry.idleTimeout());
+ flowProp.setHardTimeout(flowEntry.hardTimeout());
+ flowProp.setSwitchDpid(flowEntry.dpid().toString());
if (measureONOSFlowEntryTimeProp) {
numProperties += 3;
}
@@ -490,7 +493,7 @@
endSearchInPort = System.nanoTime();
}
- flowEntryObj.setMatchInPort(flowEntry.flowEntryMatch().inPort().value());
+ flowProp.setMatchInPort(flowEntry.flowEntryMatch().inPort().value());
if (measureONOSFlowEntryTimeProp) {
++numProperties;
}
@@ -504,67 +507,67 @@
}
}
if (flowEntry.flowEntryMatch().matchSrcMac()) {
- flowEntryObj.setMatchSrcMac(flowEntry.flowEntryMatch().srcMac().toString());
+ flowProp.setMatchSrcMac(flowEntry.flowEntryMatch().srcMac().toString());
if (measureONOSFlowEntryTimeProp) {
++numProperties;
}
}
if (flowEntry.flowEntryMatch().matchDstMac()) {
- flowEntryObj.setMatchDstMac(flowEntry.flowEntryMatch().dstMac().toString());
+ flowProp.setMatchDstMac(flowEntry.flowEntryMatch().dstMac().toString());
if (measureONOSFlowEntryTimeProp) {
++numProperties;
}
}
if (flowEntry.flowEntryMatch().matchEthernetFrameType()) {
- flowEntryObj.setMatchEthernetFrameType(flowEntry.flowEntryMatch().ethernetFrameType());
+ flowProp.setMatchEthernetFrameType(flowEntry.flowEntryMatch().ethernetFrameType());
if (measureONOSFlowEntryTimeProp) {
++numProperties;
}
}
if (flowEntry.flowEntryMatch().matchVlanId()) {
- flowEntryObj.setMatchVlanId(flowEntry.flowEntryMatch().vlanId());
+ flowProp.setMatchVlanId(flowEntry.flowEntryMatch().vlanId());
if (measureONOSFlowEntryTimeProp) {
++numProperties;
}
}
if (flowEntry.flowEntryMatch().matchVlanPriority()) {
- flowEntryObj.setMatchVlanPriority(flowEntry.flowEntryMatch().vlanPriority());
+ flowProp.setMatchVlanPriority(flowEntry.flowEntryMatch().vlanPriority());
if (measureONOSFlowEntryTimeProp) {
++numProperties;
}
}
if (flowEntry.flowEntryMatch().matchSrcIPv4Net()) {
- flowEntryObj.setMatchSrcIPv4Net(flowEntry.flowEntryMatch().srcIPv4Net().toString());
+ flowProp.setMatchSrcIPv4Net(flowEntry.flowEntryMatch().srcIPv4Net().toString());
if (measureONOSFlowEntryTimeProp) {
++numProperties;
}
}
if (flowEntry.flowEntryMatch().matchDstIPv4Net()) {
- flowEntryObj.setMatchDstIPv4Net(flowEntry.flowEntryMatch().dstIPv4Net().toString());
+ flowProp.setMatchDstIPv4Net(flowEntry.flowEntryMatch().dstIPv4Net().toString());
if (measureONOSFlowEntryTimeProp) {
++numProperties;
}
}
if (flowEntry.flowEntryMatch().matchIpProto()) {
- flowEntryObj.setMatchIpProto(flowEntry.flowEntryMatch().ipProto());
+ flowProp.setMatchIpProto(flowEntry.flowEntryMatch().ipProto());
if (measureONOSFlowEntryTimeProp) {
++numProperties;
}
}
if (flowEntry.flowEntryMatch().matchIpToS()) {
- flowEntryObj.setMatchIpToS(flowEntry.flowEntryMatch().ipToS());
+ flowProp.setMatchIpToS(flowEntry.flowEntryMatch().ipToS());
if (measureONOSFlowEntryTimeProp) {
++numProperties;
}
}
if (flowEntry.flowEntryMatch().matchSrcTcpUdpPort()) {
- flowEntryObj.setMatchSrcTcpUdpPort(flowEntry.flowEntryMatch().srcTcpUdpPort());
+ flowProp.setMatchSrcTcpUdpPort(flowEntry.flowEntryMatch().srcTcpUdpPort());
if (measureONOSFlowEntryTimeProp) {
++numProperties;
}
}
if (flowEntry.flowEntryMatch().matchDstTcpUdpPort()) {
- flowEntryObj.setMatchDstTcpUdpPort(flowEntry.flowEntryMatch().dstTcpUdpPort());
+ flowProp.setMatchDstTcpUdpPort(flowEntry.flowEntryMatch().dstTcpUdpPort());
if (measureONOSFlowEntryTimeProp) {
++numProperties;
}
@@ -583,7 +586,7 @@
endSearchOutPort = System.nanoTime();
}
- flowEntryObj.setActionOutputPort(fa.actionOutput().port().value());
+ flowProp.setActionOutputPort(fa.actionOutput().port().value());
if (measureONOSFlowEntryTimeProp) {
++numProperties;
}
@@ -598,7 +601,7 @@
}
}
if (! flowEntry.flowEntryActions().isEmpty()) {
- flowEntryObj.setActions(flowEntry.flowEntryActions().toString());
+ flowProp.setActions(flowEntry.flowEntryActions().toString());
if (measureONOSFlowEntryTimeProp) {
++numProperties;
}
@@ -606,10 +609,10 @@
// TODO: Hacks with hard-coded state names!
if (found)
- flowEntryObj.setUserState("FE_USER_MODIFY");
+ flowProp.setUserState("FE_USER_MODIFY");
else
- flowEntryObj.setUserState("FE_USER_ADD");
- flowEntryObj.setSwitchState(flowEntry.flowEntrySwitchState().toString());
+ flowProp.setUserState("FE_USER_ADD");
+ flowProp.setSwitchState(flowEntry.flowEntrySwitchState().toString());
if (measureONOSFlowEntryTimeProp) {
numProperties += 2;
}
@@ -633,6 +636,7 @@
endAddEdgeBetweenFlowPath = System.nanoTime();
}
}
+ flowProp.commitProperties();
if (measureONOSFlowEntryTimeProp) {
endAddFlowEntry = System.nanoTime();
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowProperty.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowProperty.java
new file mode 100644
index 0000000..ccc1124
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowProperty.java
@@ -0,0 +1,150 @@
+package net.onrc.onos.ofcontroller.flowmanager;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import net.onrc.onos.graph.DBOperation;
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowEntry;
+
+public class FlowProperty {
+ private Map<String, Object> map = new HashMap<>();
+ private DBOperation dbhandler;
+ private IFlowEntry flowEntry;
+
+ public FlowProperty(DBOperation dbHandler, IFlowEntry flowEntry) {
+ this.dbhandler = dbHandler;
+ this.flowEntry = flowEntry;
+ }
+
+ public void setFlowId(String value) {
+ map.put("flow_id", value);
+ }
+
+ public void setUserState(String value) {
+ map.put("user_state", value);
+ }
+
+ public void setFlowEntryId(String value) {
+ map.put("flow_entry_id", value);
+ }
+
+ public void setType(String value) {
+ map.put("type", value);
+ }
+
+ public void setInstallerId(String value) {
+ map.put("installer_id", value);
+ }
+
+ public void setFlowPathType(String value) {
+ map.put("flow_path_type", value);
+ }
+
+ public void setFlowPathUserState(String value) {
+ map.put("user_state", value);
+ }
+
+ public void flow_path_flags(Long value) {
+ map.put("flow_path_flags", value);
+ }
+
+ public void setIdleTimeout(Integer value) {
+ map.put("idle_timeout", value);
+ }
+
+ public void setHardTimeout(Integer value) {
+ map.put("hard_timeout", value);
+ }
+
+ public void setSwitchDpid(String value) {
+ map.put("switch_dpid", value);
+ }
+
+ public void setSwitchState(String value) {
+ map.put("switch_state", value);
+ }
+
+ public void setSrcSwitch(String value) {
+ map.put("src_switch", value);
+ }
+
+ public void setSrcPort(Short value) {
+ map.put("src_port", value);
+ }
+
+ public void setDstSwitch(String value) {
+ map.put("dst_switch", value);
+ }
+
+ public void setDstPort(Short value) {
+ map.put("dst_port", value);
+ }
+
+ public void setMatchSrcMac(String value) {
+ map.put("matchSrcMac", value);
+ }
+
+ public void setMatchDstMac(String value) {
+ map.put("matchDstMac", value);
+ }
+
+ public void setMatchEthernetFrameType(Short value) {
+ map.put("matchEthernetFrameType", value);
+ }
+
+ public void setMatchVlanId(Short value) {
+ map.put("matchVlanId", value);
+ }
+
+ public void setMatchVlanPriority(Byte value) {
+ map.put("matchVlanPriority", value);
+ }
+
+ public void setMatchSrcIPv4Net(String value) {
+ map.put("matchSrcIPv4Net", value);
+ }
+
+ public void setMatchDstIPv4Net(String value) {
+ map.put("matchDstIPv4Net", value);
+ }
+
+ public void setMatchIpProto(Byte value) {
+ map.put("matchIpProto", value);
+ }
+
+ public void setMatchIpToS(Byte value) {
+ map.put("matchIpToS", value);
+ }
+
+ public void setMatchInPort(Short value) {
+ map.put("matchInPort", value);
+ }
+
+ public void setMatchSrcTcpUdpPort(Short value) {
+ map.put("matchSrcTcpUdpPort", value);
+ }
+
+ public void setMatchDstTcpUdpPort(Short value) {
+ map.put("matchDstTcpUdpPort", value);
+ }
+
+ public void setActions(String value) {
+ map.put("actions", value);
+ }
+
+ public void setActionOutputPort(Short value) {
+ map.put("actionOutputPort", value);
+ }
+
+ public void setDataPathSummary(String value) {
+ map.put("data_path_summary", value);
+ }
+
+ /**
+ *
+ * @param dbhandler
+ */
+ public void commitProperties() {
+ dbhandler.setFlowProperties(flowEntry ,map);
+ }
+}