use of com.dtstack.taier.common.engine.JdbcInfo in project Taier by DTStack.
the class DatasourceService method initDefaultSource.
public void initDefaultSource(Long clusterId, EComponentType eComponentType, Long tenantId, String dataSourceName, String dataSourceDesc, Long userId) {
JdbcInfo jdbcInfo = Engine2DTOService.getJdbcInfoByClusterId(clusterId, eComponentType);
JSONObject dataJson = buildDataSourceDataJson(clusterId, eComponentType, jdbcInfo, dataSourceName);
DataSourceVO dataSourceVO = new DataSourceVO();
dataSourceVO.setDataDesc(org.apache.commons.lang3.StringUtils.isNotEmpty(dataSourceDesc) ? dataSourceDesc : "");
dataSourceVO.setDataJson(dataJson);
dataSourceVO.setCreateUserId(userId);
dataSourceVO.setActive(1);
dataSourceVO.setDataName(String.format("%s_%s", dataSourceName, eComponentType.getName().toUpperCase(Locale.ROOT)));
dataSourceVO.setTenantId(tenantId);
dataSourceVO.setDataType(getDatasourceTypeByComponent(eComponentType, jdbcInfo).getDataType());
dataSourceVO.setIsMeta(1);
addOrUpdate(dataSourceVO, userId);
}
use of com.dtstack.taier.common.engine.JdbcInfo in project Taier by DTStack.
the class BatchHadoopSelectSqlService method getMaxQueryNum.
/**
* 从简单查询sql中获取最大条数
*
* @param sql 简单查询sql
* @param tenantId 租户id
* @return 最大条数
*/
public Integer getMaxQueryNum(String sql, Long tenantId, Integer taskType) {
Matcher matcher = SIMPLE_QUERY_PATTERN.matcher(sql);
if (!matcher.find()) {
throw new RdosDefineException("该sql不符合简单查询!");
}
String limitStr = matcher.group("num");
Integer num = null;
if (StringUtils.isNotEmpty(limitStr)) {
num = Integer.parseInt(limitStr);
}
JdbcInfo jdbcInfo = Engine2DTOService.getJdbcInfo(tenantId, null, EScheduleJobType.getByTaskType(taskType));
if (Objects.isNull(num) || num > jdbcInfo.getMaxRows()) {
num = jdbcInfo.getMaxRows();
}
return num;
}
Aggregations