Fix REST data being out of date and causing fluctuating flows, links and switches
diff --git a/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java b/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java
index 931802e..502fad6 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java
@@ -29,6 +29,7 @@
public Iterable<ISwitchObject> getActiveSwitches() {
// TODO Auto-generated method stub
conn = GraphDBConnection.getInstance("/tmp/cassandra.titan");
+ conn.close(); //Commit to ensure we see latest data
return conn.utils().getActiveSwitches(conn);
}
@@ -36,6 +37,7 @@
public Iterable<ISwitchObject> getAllSwitches() {
// TODO Auto-generated method stub
conn = GraphDBConnection.getInstance("/tmp/cassandra.titan");
+ conn.close(); //Commit to ensure we see latest data
return conn.utils().getAllSwitches(conn);
}
@@ -43,6 +45,7 @@
public Iterable<ISwitchObject> getInactiveSwitches() {
// TODO Auto-generated method stub
conn = GraphDBConnection.getInstance("/tmp/cassandra.titan");
+ conn.close(); //Commit to ensure we see latest data
return conn.utils().getInactiveSwitches(conn);
}
diff --git a/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java b/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java
index c562556..1372c60 100644
--- a/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java
+++ b/src/main/java/net/floodlightcontroller/flowcache/FlowManager.java
@@ -1111,6 +1111,8 @@
ArrayList<IFlowPath> flowPathsObjArray = new ArrayList<IFlowPath>();
ArrayList<FlowPath> flowPaths = new ArrayList<FlowPath>();
+ conn.endTx(Transaction.COMMIT);
+
try {
if ((flowPathsObj = conn.utils().getAllFlowPaths(conn)) != null) {
log.debug("Get all FlowPaths: found FlowPaths");
diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/TopoLinkServiceImpl.java b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/TopoLinkServiceImpl.java
index c493887..1bd6421 100644
--- a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/TopoLinkServiceImpl.java
+++ b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/TopoLinkServiceImpl.java
@@ -34,6 +34,7 @@
public List<Link> getActiveLinks() {
// TODO Auto-generated method stub
conn = GraphDBConnection.getInstance("");
+ conn.close(); //Commit to ensure we see latest data
Iterable<ISwitchObject> switches = conn.utils().getActiveSwitches(conn);
List<Link> links = new ArrayList<Link>();
for (ISwitchObject sw : switches) {
diff --git a/src/main/java/net/onrc/onos/util/GraphDBConnection.java b/src/main/java/net/onrc/onos/util/GraphDBConnection.java
index 4d23b0d..cc3cff2 100644
--- a/src/main/java/net/onrc/onos/util/GraphDBConnection.java
+++ b/src/main/java/net/onrc/onos/util/GraphDBConnection.java
@@ -42,7 +42,7 @@
private GraphDBConnection(){ }
/* Static 'instance' method */
- public static GraphDBConnection getInstance(final String conf) {
+ public static synchronized GraphDBConnection getInstance(final String conf) {
if (GraphDBConnection.configFile == null || GraphDBConnection.configFile.isEmpty()) {
GraphDBConnection.configFile = conf;
log.debug("GraphDBConnection::Setting Config File {}", GraphDBConnection.configFile);