Search in sources :

Example 11 with EComponentType

use of com.dtstack.taier.common.enums.EComponentType in project Taier by DTStack.

the class SyncOperatorPipeline method replaceTablePath.

/**
 * 创建脏数据表的分区数据
 *
 * @param saveDirty
 * @param sqlText
 * @param taskName
 * @param sourceType
 * @return
 * @throws Exception
 */
public String replaceTablePath(boolean saveDirty, String sqlText, String taskName, Integer sourceType, String db, Long tenantId) throws Exception {
    if (StringUtils.isBlank(db)) {
        return sqlText;
    }
    JSONObject sqlObject = JSONObject.parseObject(sqlText);
    JSONObject job = sqlObject.getJSONObject("job");
    JSONObject setting = job.getJSONObject("setting");
    if (setting.containsKey("dirty")) {
        if (!saveDirty) {
            setting.remove("dirty");
            return sqlObject.toJSONString();
        }
        JSONObject dirty = setting.getJSONObject("dirty");
        String tableName = dirty.getString("tableName");
        String path = null;
        if (StringUtils.isNotEmpty(tableName)) {
            // 任务提交到task 之前 脏数据表 必须要在 ide 创建
            if (!tableName.contains(".")) {
                tableName = String.format("%s.%s", db, tableName);
            }
            Long time = Timestamp.valueOf(LocalDateTime.now()).getTime();
            String alterSql = String.format(ADD_PART_TEMP, tableName, taskName, time);
            String location = "";
            if (DataSourceType.hadoopDirtyDataSource.contains(sourceType)) {
                Cluster cluster = clusterService.getCluster(tenantId);
                Component metadataComponent = componentService.getMetadataComponent(cluster.getId());
                EComponentType metadataComponentType = EComponentType.getByCode(null == metadataComponent ? EComponentType.SPARK_THRIFT.getTypeCode() : metadataComponent.getComponentTypeCode());
                JSONObject pluginInfo = clusterService.getConfigByKey(tenantId, metadataComponentType.getConfName(), null);
                String typeName = getHiveTypeName(DataSourceType.getSourceType(sourceType));
                pluginInfo.put(ConfigConstant.TYPE_NAME_KEY, typeName);
                pluginInfo.compute(ConfigConstant.JDBCURL, (jdbcUrl, val) -> {
                    String jdbcUrlVal = (String) val;
                    if (StringUtils.isBlank(jdbcUrlVal)) {
                        return null;
                    }
                    return jdbcUrlVal.replace("/%s", environmentContext.getComponentJdbcToReplace());
                });
                workerOperator.executeQuery(pluginInfo.toJSONString(), alterSql, db);
                location = this.getTableLocation(pluginInfo, db, String.format("desc formatted %s", tableName));
            }
            if (StringUtils.isBlank(location)) {
                LOGGER.warn("table {} replace dirty path is null,dirtyType {} ", tableName, sourceType);
            }
            String partName = String.format("task_name=%s/time=%s", taskName, time);
            path = location + "/" + partName;
            dirty.put("path", path);
            setting.put("dirty", dirty);
            job.put("setting", setting);
            sqlObject.put("job", job);
        }
    }
    return sqlObject.toJSONString();
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) Cluster(com.dtstack.taier.dao.domain.Cluster) Component(com.dtstack.taier.dao.domain.Component) EComponentType(com.dtstack.taier.common.enums.EComponentType)

Example 12 with EComponentType

use of com.dtstack.taier.common.enums.EComponentType in project Taier by DTStack.

the class ClusterService method getConfigByKeyByClusterId.

public JSONObject getConfigByKeyByClusterId(Long clusterId, String componentConfName, String componentVersion) {
    // 根据组件区分kerberos
    EComponentType componentType = EComponentType.getByConfName(componentConfName);
    Component component = componentMapper.getByClusterIdAndComponentType(clusterId, componentType.getTypeCode(), componentVersion, null);
    if (null == component) {
        return null;
    }
    JSONObject configObj = componentService.getComponentByClusterId(clusterId, component.getComponentTypeCode(), false, JSONObject.class, componentVersion);
    if (configObj != null) {
        if (StringUtils.isNotBlank(component.getKerberosFileName())) {
            // 开启kerberos的kerberosFileName不为空
            KerberosConfig kerberosConfig = consoleKerberosMapper.getByComponentType(clusterId, componentType.getTypeCode(), ComponentVersionUtil.isMultiVersionComponent(componentType.getTypeCode()) ? StringUtils.isNotBlank(componentVersion) ? componentVersion : componentMapper.getDefaultComponentVersionByClusterAndComponentType(clusterId, componentType.getTypeCode()) : null);
            // 添加组件的kerberos配置信息 应用层使用
            configObj.put(ConfigConstant.KERBEROS_CONFIG, kerberosConfig);
            // 填充sftp配置项
            Map sftpMap = componentService.getComponentByClusterId(clusterId, EComponentType.SFTP.getTypeCode(), false, Map.class, null);
            if (MapUtils.isNotEmpty(sftpMap)) {
                configObj.put(EComponentType.SFTP.getConfName(), sftpMap);
            }
        }
        // 返回版本
        configObj.put(ConfigConstant.VERSION, component.getVersionValue());
        configObj.put(IS_METADATA, component.getIsMetadata());
        return configObj;
    }
    return null;
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) KerberosConfig(com.dtstack.taier.dao.domain.KerberosConfig) Component(com.dtstack.taier.dao.domain.Component) Map(java.util.Map) EComponentType(com.dtstack.taier.common.enums.EComponentType)

Example 13 with EComponentType

use of com.dtstack.taier.common.enums.EComponentType in project Taier by DTStack.

the class ComponentService method getComponentVersionByEngineType.

public List<Component> getComponentVersionByEngineType(Long tenantId, Integer taskType) {
    EScheduleJobType scheduleJobType = EScheduleJobType.getByTaskType(taskType);
    EComponentType componentType = scheduleJobType.getComponentType();
    List<Component> componentVersionList = componentMapper.getComponentVersionByEngineType(tenantId, componentType.getTypeCode());
    if (CollectionUtils.isEmpty(componentVersionList)) {
        return Collections.emptyList();
    }
    Set<String> distinct = new HashSet<>(2);
    List<Component> components = new ArrayList<>(2);
    for (Component component : componentVersionList) {
        if (distinct.add(component.getVersionValue())) {
            components.add(component);
        }
    }
    return components;
}
Also used : EScheduleJobType(com.dtstack.taier.common.enums.EScheduleJobType) ArrayList(java.util.ArrayList) Component(com.dtstack.taier.dao.domain.Component) EComponentType(com.dtstack.taier.common.enums.EComponentType) HashSet(java.util.HashSet)

Example 14 with EComponentType

use of com.dtstack.taier.common.enums.EComponentType in project Taier by DTStack.

the class ScheduleDictService method convertVersionNameToValue.

public String convertVersionNameToValue(String componentVersion, Integer taskType) {
    if (StringUtils.isBlank(componentVersion)) {
        return "";
    }
    EScheduleJobType scheduleJobType = EScheduleJobType.getByTaskType(taskType);
    EComponentType componentType = scheduleJobType.getComponentType();
    Integer dictType = DictType.getByEComponentType(componentType);
    if (null != dictType) {
        Dict versionDict = getByNameAndValue(dictType, componentVersion.trim(), null, null);
        if (null != versionDict) {
            return versionDict.getDictValue();
        }
    }
    return "";
}
Also used : EScheduleJobType(com.dtstack.taier.common.enums.EScheduleJobType) Dict(com.dtstack.taier.dao.domain.Dict) EComponentType(com.dtstack.taier.common.enums.EComponentType)

Example 15 with EComponentType

use of com.dtstack.taier.common.enums.EComponentType in project Taier by DTStack.

the class BatchComponentService method getAllDataBases.

/**
 * 获取集群对应组件下数据源中的databases
 *
 * @param clusterId         集群ID
 * @param componentTypeCode 组件类型
 * @return
 */
public List<String> getAllDataBases(Long clusterId, Integer componentTypeCode) {
    EComponentType eComponentType = EComponentType.getByCode(componentTypeCode);
    IComponentService componentService = multiEngineServiceFactory.getComponentService(componentTypeCode);
    return componentService.getAllDataBases(clusterId, eComponentType, "");
}
Also used : IComponentService(com.dtstack.taier.develop.service.develop.IComponentService) EComponentType(com.dtstack.taier.common.enums.EComponentType)

Aggregations

EComponentType (com.dtstack.taier.common.enums.EComponentType)23 JSONObject (com.alibaba.fastjson.JSONObject)10 RdosDefineException (com.dtstack.taier.common.exception.RdosDefineException)10 Component (com.dtstack.taier.dao.domain.Component)9 ComponentVO (com.dtstack.taier.scheduler.vo.ComponentVO)4 EScheduleJobType (com.dtstack.taier.common.enums.EScheduleJobType)3 Part (com.dtstack.taier.develop.model.Part)3 PartCluster (com.dtstack.taier.develop.model.PartCluster)3 EComponentScheduleType (com.dtstack.taier.common.enums.EComponentScheduleType)2 Cluster (com.dtstack.taier.dao.domain.Cluster)2 Dict (com.dtstack.taier.dao.domain.Dict)2 KerberosConfig (com.dtstack.taier.dao.domain.KerberosConfig)2 IComponentService (com.dtstack.taier.develop.service.develop.IComponentService)2 ClientTemplate (com.dtstack.taier.scheduler.impl.pojo.ClientTemplate)2 IComponentVO (com.dtstack.taier.scheduler.vo.IComponentVO)2 Map (java.util.Map)2 Transactional (org.springframework.transaction.annotation.Transactional)2 ErrorCode (com.dtstack.taier.common.exception.ErrorCode)1 Strings (com.dtstack.taier.common.util.Strings)1 com.dtstack.taier.dao.domain (com.dtstack.taier.dao.domain)1