Search in sources :

Example 1 with Dict

use of com.dtstack.taier.dao.domain.Dict 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 2 with Dict

use of com.dtstack.taier.dao.domain.Dict in project Taier by DTStack.

the class ScheduleDictService method getHadoopVersion.

private List<ClientTemplate> getHadoopVersion() {
    List<Dict> dicts = dictMapper.listDictByType(DictType.HADOOP_VERSION.type);
    Map<String, List<Dict>> versions = dicts.stream().collect(Collectors.groupingBy(Dict::getDependName));
    List<ClientTemplate> clientTemplates = new ArrayList<>(versions.size());
    for (String dependName : versions.keySet()) {
        List<Dict> keyDicts = versions.get(dependName);
        keyDicts = keyDicts.stream().sorted(Comparator.comparing(Dict::getSort)).collect(Collectors.toList());
        List<ClientTemplate> templates = keyDicts.stream().map(s -> new ClientTemplate(s.getDictName(), s.getDictValue())).collect(Collectors.toList());
        ClientTemplate vendorFolder = new ClientTemplate();
        vendorFolder.setKey(dependName);
        vendorFolder.setValues(templates);
        clientTemplates.add(vendorFolder);
    }
    clientTemplates.sort(Comparator.comparing(ClientTemplate::getKey));
    return clientTemplates;
}
Also used : java.util(java.util) Logger(org.slf4j.Logger) DictType(com.dtstack.taier.common.enums.DictType) Predicate(java.util.function.Predicate) LoggerFactory(org.slf4j.LoggerFactory) EnvironmentContext(com.dtstack.taier.common.env.EnvironmentContext) Autowired(org.springframework.beans.factory.annotation.Autowired) ComponentConfigMapper(com.dtstack.taier.dao.mapper.ComponentConfigMapper) StringUtils(org.apache.commons.lang3.StringUtils) Collectors(java.util.stream.Collectors) ComponentConfig(com.dtstack.taier.dao.domain.ComponentConfig) EComponentType(com.dtstack.taier.common.enums.EComponentType) Dict(com.dtstack.taier.dao.domain.Dict) Component(org.springframework.stereotype.Component) Stream(java.util.stream.Stream) CollectionUtils(org.springframework.util.CollectionUtils) EScheduleJobType(com.dtstack.taier.common.enums.EScheduleJobType) ClientTemplate(com.dtstack.taier.scheduler.impl.pojo.ClientTemplate) DictMapper(com.dtstack.taier.dao.mapper.DictMapper) Dict(com.dtstack.taier.dao.domain.Dict) ClientTemplate(com.dtstack.taier.scheduler.impl.pojo.ClientTemplate)

Example 3 with Dict

use of com.dtstack.taier.dao.domain.Dict in project Taier by DTStack.

the class BatchCatalogueService method initEngineCatalogue.

/**
 *  初始化函数相关的二级菜单,系统函数目录 和 自定义函数目录
 * @param tenantId
 * @param userId
 * @param name
 * @param oneBatchCatalogue
 */
private void initEngineCatalogue(Long tenantId, Long userId, String name, BatchCatalogue oneBatchCatalogue) {
    // 一级菜单初始化的时候  函数管理的一级菜单为引擎 原有的一级菜单 系统函数 自定义函数 挂在引擎下 作为二级菜单
    if (isNeedFunction(name)) {
        // 离线需要初始化的函数目录
        List<Dict> batchFunctionDictList = dictService.listByDictType(DictType.DATA_DEVELOP_FUNCTION);
        if (CollectionUtils.isNotEmpty(batchFunctionDictList)) {
            for (Dict functionDict : batchFunctionDictList) {
                // 需要 系统函数、自定义函数 挂在当前目录下
                BatchCatalogue twoBatchCatalogue = new BatchCatalogue();
                twoBatchCatalogue.setNodeName(functionDict.getDictDesc());
                twoBatchCatalogue.setLevel(CatalogueLevel.SECOND.getLevel());
                twoBatchCatalogue.setNodePid(oneBatchCatalogue.getId());
                twoBatchCatalogue.setTenantId(tenantId);
                twoBatchCatalogue.setCreateUserId(userId);
                twoBatchCatalogue.setCatalogueType(RdosBatchCatalogueTypeEnum.NORAML.getType());
                addOrUpdate(twoBatchCatalogue);
            }
        }
    }
}
Also used : Dict(com.dtstack.taier.dao.domain.Dict) BatchCatalogue(com.dtstack.taier.dao.domain.BatchCatalogue)

Example 4 with Dict

use of com.dtstack.taier.dao.domain.Dict in project Taier by DTStack.

the class BatchCatalogueService method initCatalogue.

/**
 * 绑定租户时,初始化目录信息
 * @param tenantId
 * @param userId
 * @param componentVOS 根据控制台配置的组件信息,初始化相应的目录
 */
@Transactional(rollbackFor = Exception.class)
public void initCatalogue(Long tenantId, Long userId, List<ComponentVO> componentVOS) {
    // 离线各模块的 0 级目录,任务管理、函数管理、资源管理
    List<Dict> zeroBatchCatalogueDictList = dictService.listByDictType(DictType.DATA_DEVELOP_CATALOGUE);
    List<Integer> componentTypes = componentVOS.stream().map(ComponentVO::getComponentTypeCode).collect(Collectors.toList());
    // 根据控制台配置的组件信息,获取需要初始化的 1 级目录,任务开发、SparkSQL、资源管理 等
    List<Dict> oneBatchCatalogueDictList = this.initCatalogueDictLevelByEngineType(componentTypes);
    Map<String, Set<String>> oneCatalogueValueAndNameMapping = oneBatchCatalogueDictList.stream().collect(Collectors.groupingBy(Dict::getDictValue, Collectors.mapping(Dict::getDictDesc, Collectors.toSet())));
    for (Dict zeroDict : zeroBatchCatalogueDictList) {
        // 初始化 0 级目录
        BatchCatalogue zeroBatchCatalogue = new BatchCatalogue();
        zeroBatchCatalogue.setNodeName(zeroDict.getDictDesc());
        zeroBatchCatalogue.setNodePid(DEFAULT_NODE_PID);
        zeroBatchCatalogue.setOrderVal(zeroDict.getSort());
        zeroBatchCatalogue.setLevel(CatalogueLevel.ONE.getLevel());
        zeroBatchCatalogue.setTenantId(tenantId);
        zeroBatchCatalogue.setCreateUserId(userId);
        zeroBatchCatalogue.setCatalogueType(RdosBatchCatalogueTypeEnum.NORAML.getType());
        zeroBatchCatalogue = addOrUpdate(zeroBatchCatalogue);
        if (CollectionUtils.isNotEmpty(oneCatalogueValueAndNameMapping.get(zeroDict.getDictValue()))) {
            for (String oneCatalogueName : oneCatalogueValueAndNameMapping.get(zeroDict.getDictValue())) {
                // 初始化 1 级目录
                BatchCatalogue oneBatchCatalogue = new BatchCatalogue();
                oneBatchCatalogue.setNodeName(oneCatalogueName);
                oneBatchCatalogue.setLevel(CatalogueLevel.SECOND.getLevel());
                oneBatchCatalogue.setNodePid(zeroBatchCatalogue.getId());
                oneBatchCatalogue.setTenantId(tenantId);
                oneBatchCatalogue.setCreateUserId(userId);
                oneBatchCatalogue.setCatalogueType(RdosBatchCatalogueTypeEnum.NORAML.getType());
                addOrUpdate(oneBatchCatalogue);
                if (TASK_DEVELOPE.equals(oneCatalogueName)) {
                    // 初始化任务模版
                    initTemplateCatalogue(oneBatchCatalogue, tenantId, userId);
                }
                this.initEngineCatalogue(tenantId, userId, oneCatalogueName, oneBatchCatalogue);
            }
        }
    }
}
Also used : Set(java.util.Set) Dict(com.dtstack.taier.dao.domain.Dict) BatchCatalogue(com.dtstack.taier.dao.domain.BatchCatalogue) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with Dict

use of com.dtstack.taier.dao.domain.Dict in project Taier by DTStack.

the class ComponentService method buildHdfsTypeName.

public String buildHdfsTypeName(Long tenantId, Long clusterId) {
    if (null == clusterId) {
        clusterId = clusterTenantMapper.getClusterIdByTenantId(tenantId);
    }
    Component component = getComponentByClusterId(clusterId, EComponentType.HDFS.getTypeCode(), null);
    if (null == component || StringUtils.isBlank(component.getVersionName())) {
        return "hdfs2";
    }
    String versionName = component.getVersionName();
    List<Dict> dicts = scheduleDictService.listByDictType(DictType.HDFS_TYPE_NAME);
    Optional<Dict> dbTypeNames = dicts.stream().filter(dict -> dict.getDictName().equals(versionName.trim())).findFirst();
    if (dbTypeNames.isPresent()) {
        return dbTypeNames.get().getDictValue();
    }
    String hadoopVersion = component.getVersionValue();
    if (StringUtils.isBlank(hadoopVersion)) {
        return "hdfs2";
    }
    return EComponentType.HDFS.name().toLowerCase() + hadoopVersion.charAt(0);
}
Also used : ClusterTenantMapper(com.dtstack.taier.dao.mapper.ClusterTenantMapper) KerberosConfig(com.dtstack.taier.dao.domain.KerberosConfig) EnvironmentContext(com.dtstack.taier.common.env.EnvironmentContext) Autowired(org.springframework.beans.factory.annotation.Autowired) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) StringUtils(org.apache.commons.lang3.StringUtils) ClusterMapper(com.dtstack.taier.dao.mapper.ClusterMapper) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Dict(com.dtstack.taier.dao.domain.Dict) CollectionUtils(org.apache.commons.collections.CollectionUtils) Component(com.dtstack.taier.dao.domain.Component) Service(org.springframework.stereotype.Service) Map(java.util.Map) MERGE_KRB5_CONTENT_KEY(com.dtstack.taier.pluginapi.constrant.ConfigConstant.MERGE_KRB5_CONTENT_KEY) Wrappers(com.baomidou.mybatisplus.core.toolkit.Wrappers) Cluster(com.dtstack.taier.dao.domain.Cluster) DictType(com.dtstack.taier.common.enums.DictType) MapUtils(org.apache.commons.collections.MapUtils) Set(java.util.Set) File(java.io.File) ComponentMapper(com.dtstack.taier.dao.mapper.ComponentMapper) EComponentType(com.dtstack.taier.common.enums.EComponentType) Objects(java.util.Objects) List(java.util.List) Optional(java.util.Optional) JSONObject(com.alibaba.fastjson.JSONObject) EScheduleJobType(com.dtstack.taier.common.enums.EScheduleJobType) Collections(java.util.Collections) Dict(com.dtstack.taier.dao.domain.Dict) Component(com.dtstack.taier.dao.domain.Component)

Aggregations

Dict (com.dtstack.taier.dao.domain.Dict)7 EComponentType (com.dtstack.taier.common.enums.EComponentType)5 EScheduleJobType (com.dtstack.taier.common.enums.EScheduleJobType)4 DictType (com.dtstack.taier.common.enums.DictType)3 BatchCatalogue (com.dtstack.taier.dao.domain.BatchCatalogue)3 Set (java.util.Set)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 EnvironmentContext (com.dtstack.taier.common.env.EnvironmentContext)2 RdosDefineException (com.dtstack.taier.common.exception.RdosDefineException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 Objects (java.util.Objects)2 CollectionUtils (org.apache.commons.collections.CollectionUtils)2 Service (org.springframework.stereotype.Service)2 JSONObject (com.alibaba.fastjson.JSONObject)1 Wrappers (com.baomidou.mybatisplus.core.toolkit.Wrappers)1 CatalogueLevel (com.dtstack.taier.common.enums.CatalogueLevel)1 CatalogueType (com.dtstack.taier.common.enums.CatalogueType)1 ComputeType (com.dtstack.taier.common.enums.ComputeType)1