Search in sources :

Example 6 with JdbcInfo

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);
}
Also used : DataSourceVO(com.dtstack.taier.develop.dto.devlop.DataSourceVO) JSONObject(com.alibaba.fastjson.JSONObject) JdbcInfo(com.dtstack.taier.common.engine.JdbcInfo)

Example 7 with JdbcInfo

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;
}
Also used : Matcher(java.util.regex.Matcher) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) JdbcInfo(com.dtstack.taier.common.engine.JdbcInfo)

Aggregations

JdbcInfo (com.dtstack.taier.common.engine.JdbcInfo)7 JSONObject (com.alibaba.fastjson.JSONObject)3 IClient (com.dtstack.dtcenter.loader.client.IClient)3 ISourceDTO (com.dtstack.dtcenter.loader.dto.source.ISourceDTO)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Map (java.util.Map)3 DataSourceType (com.dtstack.dtcenter.loader.source.DataSourceType)2 RdosDefineException (com.dtstack.taier.common.exception.RdosDefineException)2 ColumnMetaDTO (com.dtstack.dtcenter.loader.dto.ColumnMetaDTO)1 DataSourceVO (com.dtstack.taier.develop.dto.devlop.DataSourceVO)1 IDownload (com.dtstack.taier.develop.utils.develop.common.IDownload)1 Connection (java.sql.Connection)1 Matcher (java.util.regex.Matcher)1