use of com.ctrip.platform.dal.dao.DalQueryDao in project dal by ctripcorp.
the class SlaveFreshnessScannerMysqlTest method testBelow.
private void testBelow(int freshness) throws SQLException {
DalQueryDao dao = new DalQueryDao(DATABASE_NAME);
for (int i = 0; i < 100; i++) {
String id = dao.queryForObject(GET_DB_NAME, new StatementParameters(), new DalHints().freshness(freshness), String.class);
Assert.assertTrue(freshnessMap.get(id) <= freshness);
}
}
use of com.ctrip.platform.dal.dao.DalQueryDao in project dal by ctripcorp.
the class SlaveFreshnessScannerMysqlTest method testNoFreshness.
@Test
public void testNoFreshness() throws SQLException {
DalQueryDao dao = new DalQueryDao(NO_FRESHNESS_DATABASE_NAME);
String id = dao.queryForObject(GET_DB_NAME, new StatementParameters(), new DalHints().freshness(10), String.class);
Assert.assertEquals(NO_FRESHNESS_MASTER, id);
try {
dao = new DalQueryDao(NO_FRESHNESS_DATABASE_NAME);
id = dao.queryForObject(GET_DB_NAME, new StatementParameters(), new DalHints().freshness(10).slaveOnly(), String.class);
Assert.fail();
} catch (Exception e) {
}
}
use of com.ctrip.platform.dal.dao.DalQueryDao in project dal by ctripcorp.
the class SlaveFreshnessScannerMysqlTest method testSlaveOnlyAndFreshness.
@Test
public void testSlaveOnlyAndFreshness() throws SQLException {
int freshness = 9;
DalQueryDao dao = new DalQueryDao(DATABASE_NAME);
for (int i = 0; i < 100; i++) {
String id = dao.queryForObject(GET_DB_NAME, new StatementParameters(), new DalHints().freshness(freshness).slaveOnly(), String.class);
Assert.assertTrue(freshnessMap.get(id) <= freshness);
}
}
use of com.ctrip.platform.dal.dao.DalQueryDao in project dal by ctripcorp.
the class DalColumnMapRowMapperTest method testDalColumnMapRowMapperList.
@Test
public void testDalColumnMapRowMapperList() {
try {
StatementParameters parameters = new StatementParameters();
DalQueryDao dao = new DalQueryDao(DATABASE_NAME);
List<Map<String, Object>> result = dao.query(sqlList, parameters, hints, new DalColumnMapRowMapper());
assertEquals(3, result.size());
} catch (Exception e) {
fail();
}
}
use of com.ctrip.platform.dal.dao.DalQueryDao in project dal by ctripcorp.
the class TaskAdapter method initialize.
public void initialize(DalParser<T> parser) {
this.client = DalClientFactory.getClient(parser.getDatabaseName());
this.parser = parser;
this.logicDbName = parser.getDatabaseName();
queryDao = new DalQueryDao(parser.getDatabaseName());
rawTableName = parser.getTableName();
tableShardingEnabled = isTableShardingEnabled(logicDbName, rawTableName);
initColumnTypes();
dbCategory = getDatabaseSet(logicDbName).getDatabaseCategory();
initDbSpecific();
initSensitiveColumns();
}
Aggregations