commit | c2f5cdda5e6c3982eff6e8fb3f0410f324bc503e | [log] [tgz] |
---|---|---|
author | Pavlin Radoslavov <pavlin@onlab.us> | Tue Feb 25 14:00:09 2014 -0800 |
committer | Pavlin Radoslavov <pavlin@onlab.us> | Tue Feb 25 14:00:09 2014 -0800 |
tree | d9249f012f29aea908c9b6d0dcd41ba84c5c733c | |
parent | a88005741978d937ec3a520208cd60c295bb9e93 [diff] |
Use NetworkGraph.acquireReadLock() and releaseReadLock() when using the REST API to read switches and links from the Network Graph. Change-Id: I2fd7a874470e349bc236e351f1b84c3386b7f51a
diff --git a/src/main/java/net/onrc/onos/ofcontroller/networkgraph/web/NetworkGraphLinksResource.java b/src/main/java/net/onrc/onos/ofcontroller/networkgraph/web/NetworkGraphLinksResource.java index a244dc1..16da940 100644 --- a/src/main/java/net/onrc/onos/ofcontroller/networkgraph/web/NetworkGraphLinksResource.java +++ b/src/main/java/net/onrc/onos/ofcontroller/networkgraph/web/NetworkGraphLinksResource.java
@@ -31,10 +31,13 @@ mapper.registerModule(module); try { + graph.acquireReadLock(); return mapper.writeValueAsString(graph.getLinks()); } catch (IOException e) { log.error("Error writing link list to JSON", e); return ""; + } finally { + graph.releaseReadLock(); } } }
diff --git a/src/main/java/net/onrc/onos/ofcontroller/networkgraph/web/NetworkGraphSwitchesResource.java b/src/main/java/net/onrc/onos/ofcontroller/networkgraph/web/NetworkGraphSwitchesResource.java index 92e94f6..3e2a57c 100644 --- a/src/main/java/net/onrc/onos/ofcontroller/networkgraph/web/NetworkGraphSwitchesResource.java +++ b/src/main/java/net/onrc/onos/ofcontroller/networkgraph/web/NetworkGraphSwitchesResource.java
@@ -33,11 +33,13 @@ mapper.registerModule(module); try { + graph.acquireReadLock(); return mapper.writeValueAsString(graph.getSwitches()); } catch (IOException e) { log.error("Error writing switch list to JSON", e); return ""; + } finally { + graph.releaseReadLock(); } } - }