Network Graph Refactoring: WIP: Use the Network Graph locking mechanism
 * Renamed NetworkGraph.acquireLock() and releaseLock() to
   acquireReadLock() and releaseReadLock()
 * Added new methods NetworkGraphImpl.acquireWriteLock() and
   releaseWriteLock()
 * Use the above two locks inside the TopologyManager for
   updating the in-memory Network Topology.

Change-Id: I18d6b65e6c0ad695afb80b0bd469eb96c4f657a6
diff --git a/src/main/java/net/onrc/onos/ofcontroller/networkgraph/TopologyManager.java b/src/main/java/net/onrc/onos/ofcontroller/networkgraph/TopologyManager.java
index e484d88..b07b4ff 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/networkgraph/TopologyManager.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/networkgraph/TopologyManager.java
@@ -269,6 +269,11 @@
 	    }
 
 	    //
+	    // Lock the Network Graph while it is modified
+	    //
+	    networkGraph.acquireWriteLock();
+
+	    //
 	    // Apply the classified events.
 	    //
 	    // Apply the "add" events in the proper order:
@@ -302,6 +307,11 @@
 				 ! addedPortEvents.isEmpty());
 
 	    //
+	    // Network Graph modifications completed: Release the lock
+	    //
+	    networkGraph.releaseWriteLock();
+
+	    //
 	    // Dispatch the Topology Notification Events to the applications
 	    //
 	    dispatchNetworkGraphEvents();