use commit() and rollback() methods on IDBConnection instead of entTx() method.
diff --git a/src/main/java/net/onrc/onos/util/GraphDBConnection.java b/src/main/java/net/onrc/onos/util/GraphDBConnection.java
index e25a0c6..9a50f47 100644
--- a/src/main/java/net/onrc/onos/util/GraphDBConnection.java
+++ b/src/main/java/net/onrc/onos/util/GraphDBConnection.java
@@ -80,7 +80,6 @@
}
public FramedGraph<TitanGraph> getFramedGraph() {
-
if (isValid()) {
FramedGraph<TitanGraph> fg = new FramedGraph<TitanGraph>(graph);
return fg;
@@ -91,7 +90,6 @@
}
protected EventTransactionalGraph<TitanGraph> getEventGraph() {
-
if (isValid()) {
return eg;
} else {
@@ -106,65 +104,28 @@
}
public Boolean isValid() {
-
return (graph != null || graph.isOpen());
}
- public void startTx() {
-
- }
-
- public void endTx(Transaction tx) {
+ public void commit() {
try {
- switch (tx) {
- case COMMIT:
- graph.commit();
- case ROLLBACK:
- graph.rollback();
- }
- } catch (Exception e) {
- // TODO Auto-generated catch block
+ graph.commit();
+ }
+ catch (Exception e) {
log.error("{}", e.toString());
}
}
- public void endTx(TransactionHandle tr, Transaction tx) {
- switch (tx) {
- case COMMIT:
- if (tr != null && tr.tr != null) {
- tr.tr.commit();
- } else {
- graph.commit();
- }
- case ROLLBACK:
- if (tr != null && tr.tr != null) {
- tr.tr.rollback();
- } else {
- graph.rollback();
- }
- }
- }
-
- public void endTx(Transaction tx, GenerateEvent fire) {
-
+ public void rollback() {
try {
- if (fire.equals(GenerateEvent.TRUE)) {
- switch (tx) {
- case COMMIT:
- eg.commit();
- case ROLLBACK:
- eg.rollback();
- }
- } else {
- endTx(tx);
- }
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ graph.rollback();
+ }
+ catch (Exception e) {
+ log.error("{}", e.toString());
}
}
public void close() {
- endTx(Transaction.COMMIT);
+ commit();
}
}
diff --git a/src/main/java/net/onrc/onos/util/GraphDBOperation.java b/src/main/java/net/onrc/onos/util/GraphDBOperation.java
index 5a70dbc..858a17e 100644
--- a/src/main/java/net/onrc/onos/util/GraphDBOperation.java
+++ b/src/main/java/net/onrc/onos/util/GraphDBOperation.java
@@ -12,16 +12,6 @@
import net.onrc.onos.ofcontroller.util.FlowEntryId;
import net.onrc.onos.ofcontroller.util.FlowId;
-//import net.floodlightcontroller.core.INetMapTopologyObjects.IDeviceObject;
-//import net.floodlightcontroller.core.INetMapTopologyObjects.IFlowEntry;
-//import net.floodlightcontroller.core.INetMapTopologyObjects.IFlowPath;
-//import net.floodlightcontroller.core.INetMapTopologyObjects.IPortObject;
-//import net.floodlightcontroller.core.INetMapTopologyObjects.ISwitchObject;
-//import net.floodlightcontroller.core.ISwitchStorage.SwitchState;
-//import net.floodlightcontroller.util.FlowEntryId;
-//import net.floodlightcontroller.util.FlowId;
-import net.onrc.onos.util.GraphDBConnection.Transaction;
-
import com.thinkaurelius.titan.core.TitanGraph;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.frames.FramedGraph;
@@ -209,7 +199,6 @@
@Override
public IFlowPath getFlowPathByFlowEntry(IFlowEntry flowEntry) {
- FramedGraph<TitanGraph> fg = conn.getFramedGraph();
GremlinPipeline<Vertex, IFlowPath> pipe = new GremlinPipeline<Vertex, IFlowPath>();
pipe.start(flowEntry.asVertex());
pipe.out("flow");
@@ -273,11 +262,11 @@
}
public void commit() {
- conn.endTx(Transaction.COMMIT);
+ conn.commit();
}
public void rollback() {
- conn.endTx(Transaction.ROLLBACK);
+ conn.rollback();
}
public void close() {
diff --git a/src/main/java/net/onrc/onos/util/IDBConnection.java b/src/main/java/net/onrc/onos/util/IDBConnection.java
index e599a5e..995ce39 100644
--- a/src/main/java/net/onrc/onos/util/IDBConnection.java
+++ b/src/main/java/net/onrc/onos/util/IDBConnection.java
@@ -1,9 +1,5 @@
package net.onrc.onos.util;
-import net.onrc.onos.util.GraphDBConnection.GenerateEvent;
-import net.onrc.onos.util.GraphDBConnection.Transaction;
-import net.onrc.onos.util.GraphDBConnection.TransactionHandle;
-
import com.thinkaurelius.titan.core.TitanGraph;
import com.tinkerpop.frames.FramedGraph;
@@ -11,9 +7,7 @@
public FramedGraph<TitanGraph> getFramedGraph();
public void addEventListener(final LocalGraphChangedListener listener);
public Boolean isValid();
- public void startTx();
- public void endTx(Transaction tx);
- public void endTx(TransactionHandle tr, Transaction tx);
- public void endTx(Transaction tx, GenerateEvent fire);
+ public void commit();
+ public void rollback();
public void close();
}