Squashed commit of the following:

commit 2c41cec9145674b3bd48556c42d329c8ed1ae614
Merge: faea0fb e96a4eb
Author: Naoki Shiota <n-shiota@onlab.us>
Date:   Thu Jan 9 21:28:52 2014 -0800

    Merge branch 'dbperf2' into mergetrial

    Conflicts:
    	src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEventHandler.java
    	src/main/java/net/onrc/onos/ofcontroller/topology/Topology.java

commit e96a4ebff6f4a67693da61fcbec9cc18a940839e
Author: Naoki Shiota <n-shiota@onlab.us>
Date:   Thu Jan 9 17:47:02 2014 -0800

    Modified API call counter.

commit cd0dceecc7cc6df51c7e0b85bff1a72cae5f15cc
Author: Naoki Shiota <n-shiota@onlab.us>
Date:   Thu Jan 9 15:41:57 2014 -0800

    Added counter.

commit 93baeb6bf14124520dfcf4efe769018c7c80a0ce
Author: Naoki Shiota <n-shiota@onlab.us>
Date:   Thu Jan 9 15:13:13 2014 -0800

    Added counter of DB access.

commit a460355ed57a67b69109855f57e26ef830754bfa
Author: Naoki Shiota <n-shiota@onlab.us>
Date:   Thu Jan 9 13:51:35 2014 -0800

    Fixed bugs.

commit 19493d2d769568a798c2619d4fc70fa0d43a44ac
Author: Naoki Shiota <n-shiota@onlab.us>
Date:   Thu Jan 9 12:15:11 2014 -0800

    Fixed measurment point

commit ffc64a6f4302dd955acc47b14c12fedd10c90ffc
Author: Naoki Shiota <n-shiota@onlab.us>
Date:   Thu Jan 9 11:54:08 2014 -0800

    Modified measuring points.

commit 819e010f6131e5d00a689ea9848d38b4a554e1bd
Author: Naoki Shiota <n-shiota@onlab.us>
Date:   Thu Jan 9 11:05:20 2014 -0800

    Interted measurement code.

commit 887d7c0884b84bc0b2c0e2cfdf772468161959fc
Author: Naoki Shiota <n-shiota@onlab.us>
Date:   Thu Jan 9 01:01:27 2014 -0800

    Fixed a bug that ports are not read to memory.

commit f490f5a0677ceedcc0ef5b9e43383464b67b11be
Author: Naoki Shiota <n-shiota@onlab.us>
Date:   Thu Jan 9 00:20:28 2014 -0800

    Fixed a bug that Link addition failed.

commit 8d12e8918a1fa80947d72d312f12cf132ca13335
Author: Naoki Shiota <n-shiota@onlab.us>
Date:   Wed Jan 8 21:53:45 2014 -0800

    Merged Pankaj's refactoring code.

commit d3e8ad2b397cc5898a8218b6156721ab5c7df7bf
Author: Naoki Shiota <n-shiota@onlab.us>
Date:   Tue Jan 7 11:36:48 2014 -0800

    Added periodic execution of readFromDatabase
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEventHandler.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEventHandler.java
index 83f9731..3dc80c2 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEventHandler.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEventHandler.java
@@ -8,6 +8,8 @@
 import java.util.List;
 import java.util.Map;
 import java.util.SortedMap;
+import java.util.Timer;
+import java.util.TimerTask;
 import java.util.TreeMap;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
@@ -56,6 +58,7 @@
     private final static Logger log = LoggerFactory.getLogger(FlowEventHandler.class);
     
     private GraphDBOperation dbHandler;
+
     private FlowManager flowManager;		// The Flow Manager to use
     private IDatagridService datagridService;	// The Datagrid Service to use
     private Topology topology;			// The network topology
@@ -717,10 +720,14 @@
 
 	    switch (eventEntry.eventType()) {
 	    case ENTRY_ADD:
-		isTopologyModified |= topology.addTopologyElement(topologyElement);
+    	synchronized (topology) {
+    		isTopologyModified |= topology.addTopologyElement(topologyElement);
+    	}
 		break;
 	    case ENTRY_REMOVE:
-		isTopologyModified |= topology.removeTopologyElement(topologyElement);
+    	synchronized (topology) {
+    		isTopologyModified |= topology.removeTopologyElement(topologyElement);
+    	}
 		break;
 	    }
 	}
@@ -1017,8 +1024,12 @@
 	DataPath oldDataPath = flowPath.dataPath();
 
 	// Compute the new path
-	DataPath newDataPath = TopologyManager.computeNetworkPath(topology,
+	DataPath newDataPath;
+	synchronized (topology) {
+	newDataPath = TopologyManager.computeNetworkPath(topology,
 								  flowPath);
+	}
+	
 	if (newDataPath == null) {
 	    // We need the DataPath to compare the paths
 	    newDataPath = new DataPath();