use of com.wplatform.ddal.shards.DataSourceRepository in project jdbc-shards by wplatform.
the class JdbcWorker method getDataSource.
protected DataSource getDataSource() {
DataSourceRepository dataSourceRepository = session.getDataSourceRepository();
DataSource dataSource = dataSourceRepository.getDataSourceByShardName(shardName);
return dataSource;
}
use of com.wplatform.ddal.shards.DataSourceRepository in project jdbc-shards by wplatform.
the class TableMate method readMataData.
/**
* @param session
*/
public void readMataData(Session session, TableNode matadataNode) {
for (int retry = 0; ; retry++) {
try {
Connection conn = null;
String tableName = matadataNode.getCompositeObjectName();
String shardName = matadataNode.getShardName();
try {
DataSourceRepository dsRepository = session.getDataSourceRepository();
DataSource dataSource = dsRepository.getDataSourceByShardName(shardName);
Optional optional = Optional.build().shardName(shardName).readOnly(false);
conn = session.applyConnection(dataSource, optional);
tableName = database.identifier(tableName);
tryReadMetaData(conn, tableName);
return;
} catch (Exception e) {
throw DbException.convert(e);
} finally {
JdbcUtils.closeSilently(conn);
}
} catch (DbException e) {
if (retry >= MAX_RETRY) {
throw e;
}
}
}
}
Aggregations