本文整理汇总了Java中com.taobao.tddl.common.model.DBType类的典型用法代码示例。如果您正苦于以下问题:Java DBType类的具体用法?Java DBType怎么用?Java DBType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DBType类属于com.taobao.tddl.common.model包,在下文中一共展示了DBType类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDataSource
import com.taobao.tddl.common.model.DBType; //导入依赖的package包/类
@Override
public DataSource getDataSource(String dsKey) {
DataSourceWrapper dsw = dataSourceWrapperMap.get(dsKey);
if (dsw != null) {
dbType = dsw.getDBType();
return dsw.getWrappedDataSource();
} else {
if (createTAtomDataSource) {
TAtomDsStandard atomDs = initAtomDataSource(tGroupDataSource.getAppName(),
dsKey,
tGroupDataSource.getUnitName());
dbType = DBType.valueOf(atomDs.getDbType().name());
return atomDs;
} else {
throw new IllegalArgumentException(dsKey + " not exist!");
}
}
}
示例2: createEquityDbManager
import com.taobao.tddl.common.model.DBType; //导入依赖的package包/类
private static EquityDbManager createEquityDbManager(List<DataSourceWrapper> list, boolean isRead,
GroupExtraConfig groupExtraConfig) {
Map<String, DataSourceWrapper> dataSourceMap = new HashMap<String, DataSourceWrapper>(list.size());
Map<String, Integer> weightMap = new HashMap<String, Integer>(list.size());
DBType dbType = null;
for (DataSourceWrapper dsw : list) {
String dsKey = dsw.getDataSourceKey();
dataSourceMap.put(dsKey, dsw);
weightMap.put(dsKey, isRead ? dsw.getWeight().r : dsw.getWeight().w);
if (dbType == null) {
dbType = dsw.getDBType();
}
}
EquityDbManager equityDbManager = new EquityDbManager(dataSourceMap, weightMap, groupExtraConfig);
equityDbManager.setDbType(dbType);
return equityDbManager;
}
示例3: genFatalSQLException
import com.taobao.tddl.common.model.DBType; //导入依赖的package包/类
public SQLException genFatalSQLException() throws SQLException {
if (DBType.MYSQL.equals(dbType)) {
return new SQLException("dsClosed", "08001");// 来自MySQLExceptionSorter
} else if (DBType.ORACLE.equals(dbType)) {
return new SQLException("dsClosed", "28");// 来自OracleExceptionSorter
// //28 session has been
// killed
} else {
throw new RuntimeException("有了新的dbType而这里没有更新");
}
}
示例4: DataSourceWrapper
import com.taobao.tddl.common.model.DBType; //导入依赖的package包/类
public DataSourceWrapper(String dataSourceKey, String weightStr, DataSource wrappedDataSource, DBType dbType,
int dataSourceIndex){
this.dataSourceKey = dataSourceKey;
this.weight = new Weight(weightStr);
this.weightStr = weightStr;
this.wrappedDataSource = wrappedDataSource;
this.dbType = dbType;
this.dataSourceIndex = dataSourceIndex;
}
示例5: getDataSourceWrapper
import com.taobao.tddl.common.model.DBType; //导入依赖的package包/类
public static DataSourceWrapper getDataSourceWrapper(String dsKey, String weightStr, int index,
DataSourceFetcher fetcher) {
// 如果多个group复用一个真实dataSource,会造成所有group引用
// 这个dataSource的配置 会以最后一个dataSource的配置为准
DataSource dataSource = fetcher.getDataSource(dsKey);
DBType fetcherDbType = fetcher.getDataSourceDBType(dsKey);
// dbType = fetcherDbType == null ? dbType :
// fetcherDbType;
DataSourceWrapper dsw = new DataSourceWrapper(dsKey, weightStr, dataSource, fetcherDbType, index);
return dsw;
}
示例6: setUpBeforeClass
import com.taobao.tddl.common.model.DBType; //导入依赖的package包/类
@BeforeClass
public static void setUpBeforeClass() throws Exception {
tgds = new TGroupDataSource();
tgds.setDbGroupKey("dbKey0");
List<DataSourceWrapper> dataSourceWrappers = new ArrayList<DataSourceWrapper>();
DataSourceWrapper dsw1 = new DataSourceWrapper("db1", "rw", db1, DBType.MYSQL);
DataSourceWrapper dsw2 = new DataSourceWrapper("db2", "r", db2, DBType.MYSQL);
dataSourceWrappers.add(dsw1);
dataSourceWrappers.add(dsw2);
tgds.init(dataSourceWrappers);
}
示例7: TGroupDataSource
import com.taobao.tddl.common.model.DBType; //导入依赖的package包/类
@Test
public void 单个数据库() throws Exception {
TGroupDataSource ds = new TGroupDataSource();
DataSourceWrapper dsw = new DataSourceWrapper(DSKEY0, "rw", getMySQLDataSource(), DBType.MYSQL);
ds.init(dsw);
testCrud(ds);
}
示例8: DataSourceWrapper
import com.taobao.tddl.common.model.DBType; //导入依赖的package包/类
@Test
public void 测试DataSourceWrapper() throws Exception {
List<DataSourceWrapper> dataSourceWrappers = new ArrayList<DataSourceWrapper>();
dataSourceWrappers.add(new DataSourceWrapper(DSKEY1, "rw", getMySQLDataSource(1), DBType.MYSQL));
dataSourceWrappers.add(new DataSourceWrapper(DSKEY2, "r", getMySQLDataSource(2), DBType.MYSQL));
TGroupDataSource ds = new TGroupDataSource();
ds.setDbGroupKey(GROUP0);
ds.init(dataSourceWrappers);
testCrud(ds);
}
示例9: getMySQLDataSource
import com.taobao.tddl.common.model.DBType; //导入依赖的package包/类
@Test
public void 三个数据库_测试db1可读写_db2与db3只能读() throws Exception {
DataSource ds0 = getMySQLDataSource(0);
DataSource ds1 = getMySQLDataSource(1);
DataSource ds2 = getMySQLDataSource(2);
// 读库时最有可能从db3读,然后是db2,db1的权重最小
TGroupDataSource ds = new TGroupDataSource();
DataSourceWrapper dsw0 = new DataSourceWrapper(DSKEY0, "r10w", ds0, DBType.MYSQL);
DataSourceWrapper dsw1 = new DataSourceWrapper(DSKEY1, "r20", ds1, DBType.MYSQL);
DataSourceWrapper dsw2 = new DataSourceWrapper(DSKEY2, "r30", ds2, DBType.MYSQL);
ds.init(dsw0, dsw1, dsw2);
testCrud(ds);
}
示例10: getDbTypeEnumObj
import com.taobao.tddl.common.model.DBType; //导入依赖的package包/类
public DBType getDbTypeEnumObj() {
return DBType.valueOf(this.dbType);
}
示例11: setDbType
import com.taobao.tddl.common.model.DBType; //导入依赖的package包/类
public void setDbType(DBType dbType) {
this.dbType = dbType;
}
示例12: getDbType
import com.taobao.tddl.common.model.DBType; //导入依赖的package包/类
public DBType getDbType() {
return dbType;
}
示例13: setDbType
import com.taobao.tddl.common.model.DBType; //导入依赖的package包/类
public void setDbType(DBType dbType) {
this.dbType = dbType;
this.exceptionSorter = exceptionSorters.get(this.dbType);
}
示例14: getDBType
import com.taobao.tddl.common.model.DBType; //导入依赖的package包/类
public DBType getDBType() {
return dbType;
}