Search in sources :

Example 11 with Component

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

the class ClusterService method buildClusterConfig.

public JSONObject buildClusterConfig(Long clusterId, String componentVersion, EComponentType computeComponentType) {
    Cluster cluster = clusterMapper.getOne(clusterId);
    if (null == cluster) {
        throw new RdosDefineException(ErrorCode.CANT_NOT_FIND_CLUSTER);
    }
    JSONObject config = new JSONObject();
    List<Component> components = componentService.listAllComponents(clusterId);
    for (Component component : components) {
        EComponentType componentType = EComponentType.getByCode(component.getComponentTypeCode());
        if (!EComponentScheduleType.COMPUTE.equals(EComponentType.getScheduleTypeByComponent(component.getComponentTypeCode()))) {
            JSONObject componentConfig = componentService.getComponentByClusterId(clusterId, componentType.getTypeCode(), false, JSONObject.class, null);
            config.put(componentType.getConfName(), componentConfig);
        } else if (componentType.equals(computeComponentType)) {
            JSONObject componentConfig = componentService.getComponentByClusterId(clusterId, componentType.getTypeCode(), false, JSONObject.class, componentVersion);
            config.put(componentType.getConfName(), componentConfig);
        }
    // ignore other compute component
    }
    config.put(CLUSTER, cluster.getClusterName());
    return config;
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) Cluster(com.dtstack.taier.dao.domain.Cluster) Component(com.dtstack.taier.dao.domain.Component) EComponentType(com.dtstack.taier.common.enums.EComponentType)

Example 12 with Component

use of com.dtstack.taier.dao.domain.Component 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)

Example 13 with Component

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

the class SyncOperatorPipeline method queryLastLocation.

public String queryLastLocation(Long tenantId, String engineJobId, long startTime, long endTime, EDeployMode deployMode, String jobId, String componentVersion) {
    endTime = endTime + 1000 * 60;
    List<Component> components = componentService.listComponentsByComponentType(tenantId, EComponentType.FLINK.getTypeCode());
    if (CollectionUtils.isEmpty(components)) {
        return null;
    }
    Optional<Component> componentOptional = components.stream().filter(c -> c.getVersionValue().equals(componentVersion)).findFirst();
    if (!componentOptional.isPresent()) {
        return null;
    }
    Map<String, Object> componentConfigToMap = componentConfigService.convertComponentConfigToMap(componentOptional.get().getId(), true);
    Map<String, Object> flinkConfig = (Map<String, Object>) componentConfigToMap.get(deployMode.getMode());
    String prometheusHost = (String) flinkConfig.get("prometheusHost");
    String prometheusPort = (String) flinkConfig.get("prometheusPort");
    LOGGER.info("last job {} deployMode {} prometheus host {} port {}", jobId, deployMode.getType(), prometheusHost, prometheusPort);
    // prometheus的配置信息 从控制台获取
    PrometheusMetricQuery prometheusMetricQuery = new PrometheusMetricQuery(String.format("%s:%s", prometheusHost, prometheusPort));
    IMetric numReadMetric = MetricBuilder.buildMetric("endLocation", engineJobId, startTime, endTime, prometheusMetricQuery);
    if (numReadMetric != null) {
        String startLocation = String.valueOf(numReadMetric.getMetric());
        LOGGER.info("job {} deployMode {} startLocation [{}]", jobId, deployMode.getType(), startLocation);
        if (StringUtils.isEmpty(startLocation) || "0".equalsIgnoreCase(startLocation)) {
            return null;
        }
        return String.valueOf(numReadMetric.getMetric());
    }
    return null;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) java.util(java.util) TaskParamsUtils(com.dtstack.taier.common.util.TaskParamsUtils) ScheduleJob(com.dtstack.taier.dao.domain.ScheduleJob) EDeployMode(com.dtstack.taier.pluginapi.enums.EDeployMode) LoggerFactory(org.slf4j.LoggerFactory) LocalDateTime(java.time.LocalDateTime) EnvironmentContext(com.dtstack.taier.common.env.EnvironmentContext) IPipeline(com.dtstack.taier.scheduler.server.pipeline.IPipeline) Autowired(org.springframework.beans.factory.annotation.Autowired) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) JSONPath(com.alibaba.fastjson.JSONPath) BooleanUtils(org.apache.commons.lang.BooleanUtils) PrometheusMetricQuery(com.dtstack.taier.common.metric.prometheus.PrometheusMetricQuery) ScheduleTaskParamShade(com.dtstack.taier.dao.dto.ScheduleTaskParamShade) IMetric(com.dtstack.taier.common.metric.batch.IMetric) ComponentService(com.dtstack.taier.scheduler.service.ComponentService) ByteArrayInputStream(java.io.ByteArrayInputStream) Component(com.dtstack.taier.dao.domain.Component) ClusterService(com.dtstack.taier.scheduler.service.ClusterService) Splitter(com.google.common.base.Splitter) TaskStatus(com.dtstack.taier.pluginapi.enums.TaskStatus) DateTimeFormat(org.joda.time.format.DateTimeFormat) Charsets(com.google.common.base.Charsets) Cluster(com.dtstack.taier.dao.domain.Cluster) ScheduleTaskShade(com.dtstack.taier.dao.domain.ScheduleTaskShade) Logger(org.slf4j.Logger) ScheduleJobMapper(com.dtstack.taier.dao.mapper.ScheduleJobMapper) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) ExceptionUtil(com.dtstack.taier.pluginapi.exception.ExceptionUtil) JobParamReplace(com.dtstack.taier.scheduler.server.pipeline.JobParamReplace) Timestamp(java.sql.Timestamp) EScheduleType(com.dtstack.taier.common.enums.EScheduleType) CommonConstant(com.dtstack.taier.common.constant.CommonConstant) EComponentType(com.dtstack.taier.common.enums.EComponentType) MetricBuilder(com.dtstack.taier.common.metric.batch.MetricBuilder) DataSourceType(com.dtstack.taier.common.enums.DataSourceType) RetryUtil(com.dtstack.taier.pluginapi.util.RetryUtil) URLEncoder(java.net.URLEncoder) CollectionUtils(org.springframework.util.CollectionUtils) WorkerOperator(com.dtstack.taier.scheduler.WorkerOperator) ConfigConstant(com.dtstack.taier.pluginapi.constrant.ConfigConstant) JSONObject(com.alibaba.fastjson.JSONObject) ComponentConfigService(com.dtstack.taier.scheduler.service.ComponentConfigService) Joiner(com.google.common.base.Joiner) IMetric(com.dtstack.taier.common.metric.batch.IMetric) JSONObject(com.alibaba.fastjson.JSONObject) Component(com.dtstack.taier.dao.domain.Component) PrometheusMetricQuery(com.dtstack.taier.common.metric.prometheus.PrometheusMetricQuery)

Example 14 with Component

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

the class StoragePart method getVersionValue.

@Override
public String getVersionValue() {
    // special hdfs same as yarn
    if (StringUtils.isBlank(versionName) && EComponentType.HDFS.equals(type)) {
        Component resourceComponent = componentScheduleGroup.get(EComponentScheduleType.RESOURCE).get(0);
        versionName = resourceComponent.getVersionName();
    }
    return context.getComponentModel(type).getVersionValue(versionName);
}
Also used : Component(com.dtstack.taier.dao.domain.Component)

Example 15 with Component

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

the class StoragePart method getExtraVersionParameters.

@Override
public Long getExtraVersionParameters() {
    Component resourceComponent = componentScheduleGroup.get(EComponentScheduleType.RESOURCE).get(0);
    String resourceVersion = resourceComponent.getVersionName();
    EComponentType resourceType = EComponentType.getByCode(resourceComponent.getComponentTypeCode());
    Optional<JSONObject> resourceModelExtraVersionParameters = context.getModelExtraVersionParameters(resourceType, resourceVersion);
    if (resourceModelExtraVersionParameters.isPresent()) {
        return resourceModelExtraVersionParameters.map(res -> res.getJSONObject(type.name())).orElse(new JSONObject()).getLong(type.name());
    }
    return null;
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) Component(com.dtstack.taier.dao.domain.Component) EComponentType(com.dtstack.taier.common.enums.EComponentType)

Aggregations

Component (com.dtstack.taier.dao.domain.Component)17 EComponentType (com.dtstack.taier.common.enums.EComponentType)11 JSONObject (com.alibaba.fastjson.JSONObject)10 RdosDefineException (com.dtstack.taier.common.exception.RdosDefineException)7 Cluster (com.dtstack.taier.dao.domain.Cluster)4 EScheduleJobType (com.dtstack.taier.common.enums.EScheduleJobType)3 ArrayList (java.util.ArrayList)3 EnvironmentContext (com.dtstack.taier.common.env.EnvironmentContext)2 KerberosConfig (com.dtstack.taier.dao.domain.KerberosConfig)2 ComponentVO (com.dtstack.taier.scheduler.vo.ComponentVO)2 Map (java.util.Map)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 JSONPath (com.alibaba.fastjson.JSONPath)1 Wrappers (com.baomidou.mybatisplus.core.toolkit.Wrappers)1 CommonConstant (com.dtstack.taier.common.constant.CommonConstant)1 DataSourceType (com.dtstack.taier.common.enums.DataSourceType)1 DictType (com.dtstack.taier.common.enums.DictType)1 EComponentScheduleType (com.dtstack.taier.common.enums.EComponentScheduleType)1 EScheduleType (com.dtstack.taier.common.enums.EScheduleType)1 ErrorCode (com.dtstack.taier.common.exception.ErrorCode)1