public interface IDBCluster
IDBCluster dbCluster = new DbcpDBClusterImpl();
dbCluster.setDbRouteAlg(EnumDBRouteAlg); // 设置分片路由算法. 可选
dbCluster.setScanPackage("entity full path package"); // 可选
dbCluster.setShardInfoFromZk(true | false); // 默认为false, 可选
dbCluster.startup();
| Modifier and Type | Method and Description |
|---|---|
Lock |
createLock(String name)
create a destribute lock by give name.
|
List<DB> |
getAllMasterShardingDB(Class<?> clazz)
获取此实体对象对应的所有的分库分表引用.
|
List<DB> |
getAllMasterShardingDB(int tableNum,
String clusterName,
String tableName)
get all master sharding info.
|
List<DB> |
getAllSlaveShardingDB(Class<?> clazz,
EnumDBMasterSlave slave)
获取集群从库列表.
|
IClusterConfig |
getClusterConfig()
获取集群配置.
|
IDataLayerBuilder |
getDataLayerBuilder()
get data layer component builder.
|
Collection<DBClusterInfo> |
getDBClusterInfo()
Get all info about this cluster.
|
DBClusterInfo |
getDBClusterInfo(String clusterName)
获取集群信息.
|
IDBGenerator |
getDBGenerator()
获取db生成器.
|
IClusterRouter |
getDBRouter(String clusterName)
get cluster router.
|
List<DBTable> |
getDBTableFromJvm()
从Jvm中获取分片信息.
|
List<DBTable> |
getDBTableFromZk()
从Zookeeper中获取分片信息.
|
IIdGenerator |
getIdGenerator()
获取id生成器.
|
DBInfo |
getMasterGlobalConn(String clusterName)
获取主全局库连接.
|
DBInfo |
getSlaveGlobalDbConn(String clusterName,
EnumDBMasterSlave slave)
获取从库的全局库连接
|
ITableCluster |
getTableCluster()
获取集群表集合.
|
DB |
selectDbFromMaster(String tableName,
IShardingKey<?> value)
从主库集群中获取被操作的库表.
|
DB |
selectDbFromSlave(String tableName,
IShardingKey<?> value,
EnumDBMasterSlave slave)
从从库集群中获取被操作的库表.
|
void |
setScanPackage(String scanPackage)
设置需要扫描的实体对象包.
|
void |
setShardInfoFromZk(boolean value)
设置此集群是否从zookeeper中加载分片信息.
|
void |
setSyncAction(EnumSyncAction syncAction)
设置数据表同步动作.
|
void |
shutdown()
关闭集群.
|
void |
startup()
启动集群.
|
void |
startup(String xmlFilePath)
启动集群.
|
Lock createLock(String name)
IDataLayerBuilder getDataLayerBuilder()
IDataLayerBuildervoid setShardInfoFromZk(boolean value)
value - true:是, false:否.Collection<DBClusterInfo> getDBClusterInfo()
DBClusterInfo getDBClusterInfo(String clusterName)
clusterName - 集群名void startup()
throws DBClusterException
DBClusterException - 初始化失败void startup(String xmlFilePath) throws DBClusterException
xmlFilePath - 配置文件绝对路径DBClusterException - 初始化失败void shutdown()
throws DBClusterException
DBClusterException - 关闭失败DBInfo getMasterGlobalConn(String clusterName) throws DBClusterException
clusterName - DBClusterExceptionDBInfo getSlaveGlobalDbConn(String clusterName, EnumDBMasterSlave slave) throws DBClusterException
clusterName - slave - DBClusterExceptionDB selectDbFromMaster(String tableName, IShardingKey<?> value) throws DBClusterException
tableName - 数据表名value - 分库分表因子.DBClusterExceptionDB selectDbFromSlave(String tableName, IShardingKey<?> value, EnumDBMasterSlave slave) throws DBClusterException
slave - 从库tableName - 数据库表名value - 分库分表因子DBClusterExceptionList<DB> getAllMasterShardingDB(Class<?> clazz)
clazz - 数据对象List<DB> getAllMasterShardingDB(int tableNum, String clusterName, String tableName)
tableNum - clusterName - tableName - List<DB> getAllSlaveShardingDB(Class<?> clazz, EnumDBMasterSlave slave)
clazz - 数据对象slave - 从库号IClusterRouter getDBRouter(String clusterName)
void setSyncAction(EnumSyncAction syncAction)
syncAction - IDBGenerator getDBGenerator()
IIdGenerator getIdGenerator()
void setScanPackage(String scanPackage)
scanPackage - 包名ITableCluster getTableCluster()
IClusterConfig getClusterConfig()
Copyright © 2015. All rights reserved.