Search in sources :

Example 11 with IClient

use of com.dtstack.dtcenter.loader.client.IClient in project Taier by DTStack.

the class HiveSelectDownload method init.

// 初始downloader和相关参数
private void init() throws Exception {
    Map<String, String> partitionMap = Maps.newHashMap();
    if (StringUtils.isNotEmpty(partition)) {
        List<Pair<String, String>> stringStringPair = splitPartition(partition);
        if (CollectionUtils.isNotEmpty(stringStringPair)) {
            for (int i = 0; i < stringStringPair.size(); i++) {
                partitionMap.put(stringStringPair.get(i).getKey(), stringStringPair.get(i).getValue());
            }
        }
    }
    // 获取client
    ISourceDTO sourceDTO = Engine2DTOService.get(tenantId, null, dataSourceType, db, jdbcInfo);
    IClient client = ClientCache.getClient(dataSourceType);
    SqlQueryDTO queryDTO = SqlQueryDTO.builder().tableName(tableName).columns(queryFieldNames).partitionColumns(partitionMap).build();
    pluginDownloader = client.getDownloader(sourceDTO, queryDTO);
    this.columnNames = pluginDownloader.getMetaInfo();
    if (CollectionUtils.isNotEmpty(queryFieldNames)) {
        // permissionStyle为true则展示无权限字段
        if (permissionStyle) {
            // 获取不展示列添加到fieldNameList后面
            excludeCol = columnNames.stream().filter(column -> {
                Boolean flag = false;
                for (String clumnName : queryFieldNames) {
                    flag = clumnName.equalsIgnoreCase(column);
                    if (flag) {
                        break;
                    }
                }
                return !flag;
            }).collect(Collectors.toList());
            fieldNamesShow.addAll(excludeCol);
        }
    } else {
        fieldNamesShow = new ArrayList<>(columnNames);
        queryFieldNames = columnNames;
    }
}
Also used : IClient(com.dtstack.dtcenter.loader.client.IClient) SqlQueryDTO(com.dtstack.dtcenter.loader.dto.SqlQueryDTO) ISourceDTO(com.dtstack.dtcenter.loader.dto.source.ISourceDTO) Pair(org.apache.commons.math3.util.Pair)

Example 12 with IClient

use of com.dtstack.dtcenter.loader.client.IClient in project Taier by DTStack.

the class JdbcServiceImpl method executeQueryMapResult.

@Override
public List<Map<String, Object>> executeQueryMapResult(Long tenantId, Long userId, EScheduleJobType eScheduleJobType, String schema, String sql) {
    JdbcInfo jdbcInfo = Engine2DTOService.getJdbcInfo(tenantId, userId, eScheduleJobType);
    ISourceDTO iSourceDTO = Engine2DTOService.get(tenantId, userId, Engine2DTOService.jobTypeTransitionDataSourceType(eScheduleJobType, jdbcInfo.getVersion()).getVal(), schema, jdbcInfo);
    IClient client = ClientCache.getClient(iSourceDTO.getSourceType());
    LOGGER.info("集群执行SQL查询,tenantId:{},userId:{},jobType:{},schema:{},sql:{}", tenantId, userId, eScheduleJobType.getType(), schema, sql);
    List<Map<String, Object>> list = client.executeQuery(iSourceDTO, SqlQueryDTO.builder().sql(sql).limit(jdbcInfo.getMaxRows()).queryTimeout(jdbcInfo.getQueryTimeout()).build());
    return list;
}
Also used : IClient(com.dtstack.dtcenter.loader.client.IClient) ISourceDTO(com.dtstack.dtcenter.loader.dto.source.ISourceDTO) Map(java.util.Map) JdbcInfo(com.dtstack.taier.common.engine.JdbcInfo)

Example 13 with IClient

use of com.dtstack.dtcenter.loader.client.IClient in project Taier by DTStack.

the class JdbcServiceImpl method createDatabase.

@Override
public void createDatabase(Long clusterId, EComponentType eComponentType, String schema, String comment) {
    ISourceDTO iSourceDTO = Engine2DTOService.getByClusterId(clusterId, eComponentType, "");
    IClient client = ClientCache.getClient(iSourceDTO.getSourceType());
    LOGGER.info("集群创建数据库操作,clusterId:{},sourceType:{},dbName:{}", clusterId, iSourceDTO.getSourceType(), schema);
    client.createDatabase(iSourceDTO, schema, comment);
}
Also used : IClient(com.dtstack.dtcenter.loader.client.IClient) ISourceDTO(com.dtstack.dtcenter.loader.dto.source.ISourceDTO)

Example 14 with IClient

use of com.dtstack.dtcenter.loader.client.IClient in project Taier by DTStack.

the class JdbcServiceImpl method executeQueryWithoutResult.

@Override
public Boolean executeQueryWithoutResult(Long tenantId, Long userId, EScheduleJobType eScheduleJobType, String schema, String sql) {
    ISourceDTO iSourceDTO = Engine2DTOService.get(tenantId, userId, eScheduleJobType, schema);
    IClient client = ClientCache.getClient(iSourceDTO.getSourceType());
    LOGGER.info("集群执行SQL,tenantId:{},userId:{},jobType:{},schema:{},sql:{}", tenantId, userId, eScheduleJobType.getType(), schema, sql);
    client.executeSqlWithoutResultSet(iSourceDTO, SqlQueryDTO.builder().sql(sql).build());
    return Boolean.TRUE;
}
Also used : IClient(com.dtstack.dtcenter.loader.client.IClient) ISourceDTO(com.dtstack.dtcenter.loader.dto.source.ISourceDTO)

Example 15 with IClient

use of com.dtstack.dtcenter.loader.client.IClient in project Taier by DTStack.

the class JdbcServiceImpl method getConnection.

@Override
public Connection getConnection(Long tenantId, Long userId, EScheduleJobType eScheduleJobType, String dbName, String taskParam) {
    ISourceDTO iSourceDTO = Engine2DTOService.get(tenantId, userId, eScheduleJobType, dbName);
    IClient client = ClientCache.getClient(iSourceDTO.getSourceType());
    return client.getCon(iSourceDTO, taskParam);
}
Also used : IClient(com.dtstack.dtcenter.loader.client.IClient) ISourceDTO(com.dtstack.dtcenter.loader.dto.source.ISourceDTO)

Aggregations

IClient (com.dtstack.dtcenter.loader.client.IClient)23 ISourceDTO (com.dtstack.dtcenter.loader.dto.source.ISourceDTO)20 JSONObject (com.alibaba.fastjson.JSONObject)9 ArrayList (java.util.ArrayList)8 ColumnMetaDTO (com.dtstack.dtcenter.loader.dto.ColumnMetaDTO)7 SqlQueryDTO (com.dtstack.dtcenter.loader.dto.SqlQueryDTO)7 BatchDataSource (com.dtstack.taier.dao.domain.BatchDataSource)6 DtCenterDefException (com.dtstack.taier.common.exception.DtCenterDefException)5 RdosDefineException (com.dtstack.taier.common.exception.RdosDefineException)5 IOException (java.io.IOException)5 PubSvcDefineException (com.dtstack.taier.common.exception.PubSvcDefineException)4 SftpException (com.jcraft.jsch.SftpException)4 Map (java.util.Map)4 DataSourceType (com.dtstack.dtcenter.loader.source.DataSourceType)3 JdbcInfo (com.dtstack.taier.common.engine.JdbcInfo)3 List (java.util.List)3 Connection (java.sql.Connection)2 ITable (com.dtstack.dtcenter.loader.client.ITable)1 Table (com.dtstack.dtcenter.loader.dto.Table)1 HdfsSourceDTO (com.dtstack.dtcenter.loader.dto.source.HdfsSourceDTO)1