use of com.dtstack.dtcenter.loader.dto.source.ISourceDTO 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;
}
}
use of com.dtstack.dtcenter.loader.dto.source.ISourceDTO 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;
}
use of com.dtstack.dtcenter.loader.dto.source.ISourceDTO 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);
}
use of com.dtstack.dtcenter.loader.dto.source.ISourceDTO 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;
}
use of com.dtstack.dtcenter.loader.dto.source.ISourceDTO 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);
}
Aggregations