mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
hbase support
This commit is contained in:
@@ -8,11 +8,13 @@ import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.client.HTableInterface;
|
||||
import org.apache.hadoop.hbase.client.HTablePool;
|
||||
|
||||
import com.alibaba.druid.hbase.mapping.HMapping;
|
||||
import com.alibaba.druid.logging.Log;
|
||||
import com.alibaba.druid.logging.LogFactory;
|
||||
|
||||
public class HEngine {
|
||||
private final static Log LOG = LogFactory.getLog(HEngine.class);
|
||||
|
||||
private final static Log LOG = LogFactory.getLog(HEngine.class);
|
||||
|
||||
private static ConcurrentMap<String, HEngine> engines = new ConcurrentHashMap<String, HEngine>();
|
||||
|
||||
@@ -28,11 +30,12 @@ public class HEngine {
|
||||
|
||||
// =============================
|
||||
|
||||
private final String url;
|
||||
private final String url;
|
||||
|
||||
private HTablePool tablePool;
|
||||
private int htablePoolMaxSize = 256;
|
||||
private Configuration config;
|
||||
private HTablePool tablePool;
|
||||
private int htablePoolMaxSize = 256;
|
||||
private Configuration config;
|
||||
private ConcurrentMap<String, HMapping> mappings = new ConcurrentHashMap<String, HMapping>();
|
||||
|
||||
public HEngine(String url, Properties connectProperties){
|
||||
super();
|
||||
@@ -64,6 +67,10 @@ public class HEngine {
|
||||
return config;
|
||||
}
|
||||
|
||||
public ConcurrentMap<String, HMapping> getMappings() {
|
||||
return mappings;
|
||||
}
|
||||
|
||||
public synchronized HTableInterface getHTable(String tableName) {
|
||||
if (tablePool == null) {
|
||||
tablePool = new HTablePool(config, htablePoolMaxSize);
|
||||
|
||||
@@ -7,9 +7,19 @@ import java.util.Map;
|
||||
|
||||
public class HMapping {
|
||||
|
||||
private String tableName;
|
||||
|
||||
private Map<String, HMappingColumn> columns = new LinkedHashMap<String, HMappingColumn>();
|
||||
private HMappingColumn keyColumn;
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public Collection<HMappingColumn> getColumns() {
|
||||
return Collections.unmodifiableCollection(columns.values());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user