Search in sources :

Example 1 with KerberosConfig

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

the class ConsoleClusterService method getConsoleClusterInfo.

/**
 * 获取集群信息详情 需要根据组件分组
 *
 * @param clusterId
 * @return
 */
public ClusterVO getConsoleClusterInfo(Long clusterId) {
    Cluster cluster = clusterMapper.getOne(clusterId);
    if (null == cluster) {
        return new ClusterVO();
    }
    ClusterVO clusterVO = ClusterVO.toVO(cluster);
    // 查询默认版本或者多个版本
    List<com.dtstack.taier.dao.domain.Component> components = componentMapper.listByClusterId(clusterId, null, false);
    List<IComponentVO> componentConfigs = componentConfigService.getComponentVoByComponent(components, true, clusterId, true, true);
    Table<Integer, String, KerberosConfig> kerberosTable = null;
    // kerberos的配置
    kerberosTable = HashBasedTable.create();
    for (KerberosConfig kerberosConfig : consoleKerberosMapper.getByClusters(clusterId)) {
        kerberosTable.put(kerberosConfig.getComponentType(), StringUtils.isBlank(kerberosConfig.getComponentVersion()) ? StringUtils.EMPTY : kerberosConfig.getComponentVersion(), kerberosConfig);
    }
    Map<EComponentScheduleType, List<IComponentVO>> scheduleType = new HashMap<>(4);
    // 组件根据用途分组(计算,资源)
    if (CollectionUtils.isNotEmpty(componentConfigs)) {
        scheduleType = componentConfigs.stream().collect(Collectors.groupingBy(c -> EComponentType.getScheduleTypeByComponent(c.getComponentTypeCode())));
    }
    List<SchedulingVo> schedulingVos = convertComponentToScheduling(kerberosTable, scheduleType);
    clusterVO.setScheduling(schedulingVos);
    clusterVO.setCanModifyMetadata(checkMetadata(clusterId, components));
    return clusterVO;
}
Also used : IComponentVO(com.dtstack.taier.scheduler.vo.IComponentVO) ClusterVO(com.dtstack.taier.develop.vo.console.ClusterVO) KerberosConfig(com.dtstack.taier.dao.domain.KerberosConfig) Cluster(com.dtstack.taier.dao.domain.Cluster) EComponentScheduleType(com.dtstack.taier.common.enums.EComponentScheduleType) SchedulingVo(com.dtstack.taier.scheduler.vo.SchedulingVo) Component(org.springframework.stereotype.Component)

Example 2 with KerberosConfig

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

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

the class ClusterService method setComponentSftpDir.

/**
 * 填充对应的组件信息
 *
 * @param clusterId
 * @param clusterConfigJson
 * @param pluginJson
 * @param componentType
 */
private void setComponentSftpDir(Long clusterId, JSONObject clusterConfigJson, JSONObject pluginJson, EComponentType componentType) {
    // sftp Dir
    JSONObject sftpConfig = clusterConfigJson.getJSONObject(EComponentType.SFTP.getConfName());
    if (null != sftpConfig) {
        pluginJson.put(EComponentType.SFTP.getConfName(), sftpConfig);
    }
    KerberosConfig kerberosConfig = consoleKerberosMapper.getByComponentType(clusterId, componentType.getTypeCode(), ComponentVersionUtil.isMultiVersionComponent(componentType.getTypeCode()) ? componentMapper.getDefaultComponentVersionByClusterAndComponentType(clusterId, componentType.getTypeCode()) : null);
    if (null != kerberosConfig) {
        Integer openKerberos = kerberosConfig.getOpenKerberos();
        String remotePath = kerberosConfig.getRemotePath();
        Preconditions.checkState(StringUtils.isNotEmpty(remotePath), "remotePath can not be null");
        pluginJson.fluentPut("openKerberos", null != openKerberos && openKerberos > 0).fluentPut("remoteDir", remotePath).fluentPut("principalFile", kerberosConfig.getName()).fluentPut("principal", kerberosConfig.getPrincipal()).fluentPut("krbName", kerberosConfig.getKrbName()).fluentPut("kerberosFileTimestamp", kerberosConfig.getGmtModified()).fluentPut(MERGE_KRB5_CONTENT_KEY, kerberosConfig.getMergeKrbContent());
        // 如果 hiveSQL  impalaSQL中没有yarnConf 需要添加yarnConf做kerberos认证
        pluginJson.putIfAbsent(EComponentType.YARN.getConfName(), clusterConfigJson.getJSONObject(EComponentType.YARN.getConfName()));
    }
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) KerberosConfig(com.dtstack.taier.dao.domain.KerberosConfig)

Example 4 with KerberosConfig

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

the class ConsoleClusterService method convertComponentToScheduling.

private List<SchedulingVo> convertComponentToScheduling(Table<Integer, String, KerberosConfig> kerberosTable, Map<EComponentScheduleType, List<IComponentVO>> scheduleType) {
    List<SchedulingVo> schedulingVos = new ArrayList<>();
    // 为空也返回
    for (EComponentScheduleType value : EComponentScheduleType.values()) {
        SchedulingVo schedulingVo = new SchedulingVo();
        schedulingVo.setSchedulingCode(value.getType());
        schedulingVo.setSchedulingName(value.getName());
        List<IComponentVO> componentVoList = scheduleType.getOrDefault(value, Collections.emptyList());
        if (Objects.nonNull(kerberosTable) && !kerberosTable.isEmpty() && CollectionUtils.isNotEmpty(componentVoList)) {
            componentVoList.forEach(component -> {
                // 组件每个版本设置k8s参数
                for (ComponentVO componentVO : component.loadComponents()) {
                    KerberosConfig kerberosConfig;
                    EComponentType type = EComponentType.getByCode(componentVO.getComponentTypeCode());
                    if (type == EComponentType.YARN || type == EComponentType.SPARK_THRIFT || type == EComponentType.HIVE_SERVER) {
                        kerberosConfig = kerberosTable.get(type.getTypeCode(), StringUtils.EMPTY);
                    } else {
                        kerberosConfig = kerberosTable.get(componentVO.getComponentTypeCode(), StringUtils.isBlank(componentVO.getVersionValue()) ? StringUtils.EMPTY : componentVO.getVersionValue());
                    }
                    if (Objects.nonNull(kerberosConfig)) {
                        componentVO.setPrincipal(kerberosConfig.getPrincipal());
                        componentVO.setPrincipals(kerberosConfig.getPrincipals());
                        componentVO.setMergeKrb5Content(kerberosConfig.getMergeKrbContent());
                    }
                }
            });
        }
        schedulingVo.setComponents(componentVoList);
        schedulingVos.add(schedulingVo);
    }
    return schedulingVos;
}
Also used : IComponentVO(com.dtstack.taier.scheduler.vo.IComponentVO) IComponentVO(com.dtstack.taier.scheduler.vo.IComponentVO) ComponentVO(com.dtstack.taier.scheduler.vo.ComponentVO) EComponentScheduleType(com.dtstack.taier.common.enums.EComponentScheduleType) KerberosConfig(com.dtstack.taier.dao.domain.KerberosConfig) SchedulingVo(com.dtstack.taier.scheduler.vo.SchedulingVo) EComponentType(com.dtstack.taier.common.enums.EComponentType)

Aggregations

KerberosConfig (com.dtstack.taier.dao.domain.KerberosConfig)4 JSONObject (com.alibaba.fastjson.JSONObject)2 EComponentScheduleType (com.dtstack.taier.common.enums.EComponentScheduleType)2 EComponentType (com.dtstack.taier.common.enums.EComponentType)2 IComponentVO (com.dtstack.taier.scheduler.vo.IComponentVO)2 SchedulingVo (com.dtstack.taier.scheduler.vo.SchedulingVo)2 Cluster (com.dtstack.taier.dao.domain.Cluster)1 Component (com.dtstack.taier.dao.domain.Component)1 ClusterVO (com.dtstack.taier.develop.vo.console.ClusterVO)1 ComponentVO (com.dtstack.taier.scheduler.vo.ComponentVO)1 Map (java.util.Map)1 Component (org.springframework.stereotype.Component)1