@@ -0,0 +1,1158 @@
+/**%0A * %0A */%0Apackage org.hivedb.meta.persistence;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Aimport javax.sql.DataSource;%0A%0Aimport org.hivedb.meta.Node;%0Aimport org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy;%0A%0Apublic class CachingDataSourceProvider implements DataSourceProvider %7B%0A%09%0A%09private static CachingDataSourceProvider INSTANCE = new CachingDataSourceProvider();%0A%09%0A%09private Map%3CString, LazyConnectionDataSourceProxy%3E cache = new HashMap%3CString, LazyConnectionDataSourceProxy%3E();%0A%09//private Map%3CString, DataSource%3E cache = new HashMap%3CString, DataSource%3E();%0A%09%0A%09private CachingDataSourceProvider() %7B%0A%09%7D%0A%09%0A%09public DataSource getDataSource(Node node) %7B%0A%09%09return getDataSource(node.getUri());%0A%09%7D%0A%0A%09public DataSource getDataSource(String uri) %7B%0A%09%09LazyConnectionDataSourceProxy ds = cache.get(uri);%0A%09%09//DataSource ds = cache.get(uri);%0A%09%09if (ds == null) %7B%0A%09%09%09ds = new LazyConnectionDataSourceProxy(new HiveBasicDataSource(uri, HiveBasicDataSource.getDefaultPoolSize()));%0A%09%09%09//ds = new HiveBasicDataSource(uri);%0A%09%09%09cache.put(uri, ds);%0A%09%09%7D%0A%09%09return ds;%0A%09%7D%0A%09%0A%09public static CachingDataSourceProvider getInstance() %7B%0A%09%09return INSTANCE;%0A%09%7D%0A%7D%0A

Enable DataSource caching