Added ThreadLocal
diff --git a/src/main/java/net/onrc/onos/graph/RamCloudDBConnection.java b/src/main/java/net/onrc/onos/graph/RamCloudDBConnection.java
index c53e66e..3fcbfe9 100644
--- a/src/main/java/net/onrc/onos/graph/RamCloudDBConnection.java
+++ b/src/main/java/net/onrc/onos/graph/RamCloudDBConnection.java
@@ -20,12 +20,19 @@
public class RamCloudDBConnection extends DBConnection {
private RamCloudGraph graph;
private static Logger log = LoggerFactory.getLogger(RamCloudDBConnection.class);
+
+ public static final ThreadLocal<RamCloudGraph> RamCloudThreadLocal = new ThreadLocal<RamCloudGraph>();
public RamCloudDBConnection(final String dbConfigFile) {
- final String coordinatorURL = open(getConfiguration(new File(dbConfigFile)));
- System.out.println("coordinatorURL "+ coordinatorURL);
+ //final String coordinatorURL = open(getConfiguration(new File(dbConfigFile)));
+ //System.out.println("coordinatorURL "+ coordinatorURL);
//graph = new RamCloudGraph(coordinatorURL);
- graph = new RamCloudGraph("fast+udp:host=10.128.100.36,port=12246");
+ graph = RamCloudThreadLocal.get();
+ System.out.println("ThreadId = " + Thread.currentThread().getId() + "graph = " + graph);
+ if (graph == null) {
+ graph = new RamCloudGraph("fast+udp:host=10.128.100.36,port=12246");
+ RamCloudThreadLocal.set(graph);
+ }
}
@Override