blob: b58f48921476df4df7ddf105a2f8d4a6aa2b2e4b [file] [log] [blame]
yoshi0451f282013-11-22 15:48:55 -08001/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5package net.onrc.onos.graph;
6
7import java.util.ArrayList;
8import java.util.HashMap;
9import java.util.List;
10import java.util.Map;
11
12/**
13 *
14 * @author nickkaranatsios
15 */
16public class GraphDBManager {
yoshi56b4eda2013-12-04 13:57:31 -080017 //private static ThreadLocal<HashMap<String, DBConnection>> connections = new ThreadLocal<HashMap<String, DBConnection>>();
yoshi2db7ff42013-11-25 19:30:25 -080018 private static DBOperation operation = null;
yoshi56b4eda2013-12-04 13:57:31 -080019 /*
yoshi0451f282013-11-22 15:48:55 -080020 static Map<String, DBConnection> getConnectionMap() {
21 if (connections.get() == null) {
22 connections.set(new HashMap<String, DBConnection>());
23 }
24 return connections.get();
25 }
yoshi56b4eda2013-12-04 13:57:31 -080026*/
yoshi0451f282013-11-22 15:48:55 -080027 public static DBOperation getDBOperation(final String dbStore, final String dbConfigFile) {
yoshid38cd312013-12-02 19:54:44 -080028 if (dbStore.equals("ramcloud")) {
29 operation = new RamCloudDBOperation();
30 } else if (dbStore.equals("titan")) {
31 operation = new TitanDBOperation();
32 }
33 if (operation != null) {
34 operation.conn = GraphDBManager.getConnection(dbStore, dbConfigFile);
yoshi2db7ff42013-11-25 19:30:25 -080035 }
yoshi95ff5c22013-11-25 17:00:18 -080036 return operation;
yoshi0451f282013-11-22 15:48:55 -080037 }
38
39 public static DBConnection getConnection(final String dbStore, final String dbConfigFile) {
yoshi56b4eda2013-12-04 13:57:31 -080040 //DBConnection conn = getConnectionMap().get(dbStore);
41 DBConnection conn = null;
42 //if (conn == null) {
yoshi0451f282013-11-22 15:48:55 -080043 if (dbStore.equals("ramcloud")) {
44 conn = new RamCloudDBConnection(dbConfigFile);
45 } else if (dbStore.equals("titan")) {
46 conn = new TitanDBConnection(dbConfigFile);
47 }
48
yoshi56b4eda2013-12-04 13:57:31 -080049 //GraphDBManager.getConnectionMap().put(dbStore, conn);
50 //} else {
51 // GraphDBManager.getConnectionMap().get(dbStore);
52 //}
yoshi0451f282013-11-22 15:48:55 -080053 return conn;
54 }
yoshi56b4eda2013-12-04 13:57:31 -080055/*
yoshi0451f282013-11-22 15:48:55 -080056 static List<DBConnection> getConnections() {
57 return new ArrayList<DBConnection>(getConnectionMap().values());
58 }
yoshi56b4eda2013-12-04 13:57:31 -080059 */
yoshi0451f282013-11-22 15:48:55 -080060}