Search in sources :

Example 16 with RdosDefineException

use of com.dtstack.taier.common.exception.RdosDefineException in project Taier by DTStack.

the class CommonResource method newInstance.

public ComputeResourceType newInstance(JobClient jobClient) {
    EScheduleJobType taskType = EScheduleJobType.getByTaskType(jobClient.getTaskType());
    CommonResource resource = resources.computeIfAbsent(taskType, k -> {
        CommonResource commonResource = null;
        switch(taskType) {
            case SYNC:
                commonResource = new FlinkResource();
                commonResource.setClusterMapper(clusterMapper);
                commonResource.setClusterService(clusterService);
                commonResource.setComponentService(componentService);
                commonResource.setClusterTenantMapper(clusterTenantMapper);
                break;
            case SPARK_SQL:
            case SPARK:
                commonResource = this;
                break;
            default:
                throw new RdosDefineException("taskType:" + taskType + " is not support.");
        }
        return commonResource;
    });
    return resource.getComputeResourceType(jobClient);
}
Also used : EScheduleJobType(com.dtstack.taier.common.enums.EScheduleJobType) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException)

Example 17 with RdosDefineException

use of com.dtstack.taier.common.exception.RdosDefineException in project Taier by DTStack.

the class FlinkResource method getComputeResourceType.

@Override
public ComputeResourceType getComputeResourceType(JobClient jobClient) {
    long tenantId = jobClient.getTenantId();
    EComponentType componentType = resourceComponents.computeIfAbsent(tenantId, e -> getResourceEComponentType(jobClient));
    Properties properties = jobClient.getConfProperties();
    ComputeType computeType = jobClient.getComputeType();
    String modeStr = properties.getProperty(FLINK_TASK_RUN_MODE_KEY);
    if (EComponentType.FLINK.getTypeCode().equals(componentType.getTypeCode())) {
        // flink on standalone
        return ComputeResourceType.FlinkOnStandalone;
    } else if (EComponentType.YARN.getTypeCode().equals(componentType.getTypeCode())) {
        if (StringUtils.isEmpty(modeStr)) {
            if (ComputeType.STREAM == computeType) {
                return ComputeResourceType.Yarn;
            } else {
                return ComputeResourceType.FlinkYarnSession;
            }
        }
        if (SESSION.equalsIgnoreCase(modeStr)) {
            return ComputeResourceType.FlinkYarnSession;
        } else if (PER_JOB.equalsIgnoreCase(modeStr)) {
            return ComputeResourceType.Yarn;
        } else if (STANDALONE.equals(modeStr)) {
            return ComputeResourceType.FlinkOnStandalone;
        }
    }
    throw new RdosDefineException("not support mode: " + modeStr);
}
Also used : RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) Properties(java.util.Properties) ComputeType(com.dtstack.taier.pluginapi.enums.ComputeType) EComponentType(com.dtstack.taier.common.enums.EComponentType)

Example 18 with RdosDefineException

use of com.dtstack.taier.common.exception.RdosDefineException in project Taier by DTStack.

the class FlinkResource method getResourceEComponentType.

public EComponentType getResourceEComponentType(JobClient jobClient) {
    long tenantId = jobClient.getTenantId();
    Long clusterId = clusterTenantMapper.getClusterIdByTenantId(tenantId);
    Component flinkComponent = componentService.getComponentByClusterId(clusterId, EComponentType.FLINK.getTypeCode(), null);
    if (null != flinkComponent) {
        if (EDeployType.STANDALONE.getType() == flinkComponent.getDeployType()) {
            return EComponentType.FLINK;
        } else if (EDeployType.YARN.getType() == flinkComponent.getDeployType()) {
            return EComponentType.YARN;
        }
    }
    throw new RdosDefineException("No found resource EComponentType");
}
Also used : RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) Component(com.dtstack.taier.dao.domain.Component)

Example 19 with RdosDefineException

use of com.dtstack.taier.common.exception.RdosDefineException in project Taier by DTStack.

the class AbstractJobBuilder method getTriggerRange.

/**
 * 校验时间是否符合规范,且获得时间范围
 *
 * @param triggerDay 目标时间
 * @param beginTime  开始时间
 * @param endTime    结束时间
 * @return 范围时间
 */
private Pair<Date, Date> getTriggerRange(String triggerDay, String beginTime, String endTime) {
    if (StringUtils.isBlank(triggerDay)) {
        throw new RdosDefineException("triggerDay is not null");
    }
    if (StringUtils.isBlank(beginTime)) {
        beginTime = "00:00:00";
    }
    if (StringUtils.isBlank(endTime)) {
        endTime = "23:59:59";
    }
    String start = triggerDay + " " + beginTime + ":00";
    String end = triggerDay + " " + endTime + ":59";
    Date startDate = DateUtil.parseDate(start, DateUtil.STANDARD_DATETIME_FORMAT, Locale.CHINA);
    Date endDate = DateUtil.parseDate(end, DateUtil.STANDARD_DATETIME_FORMAT, Locale.CHINA);
    if (startDate == null || endDate == null) {
        throw new RdosDefineException("triggerDay or beginTime or endTime invalid");
    }
    return new ImmutablePair<>(startDate, endDate);
}
Also used : ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) Date(java.util.Date)

Example 20 with RdosDefineException

use of com.dtstack.taier.common.exception.RdosDefineException in project Taier by DTStack.

the class BatchResourceService method uploadHDFSFileWithResource.

/**
 * 上次资源文件到hdsf上
 * @param tenantId
 * @param resourceName
 * @param originalFilename
 * @param tmpPath
 * @return
 */
private String uploadHDFSFileWithResource(Long tenantId, String resourceName, String originalFilename, String tmpPath) {
    if (StringUtils.isBlank(originalFilename) || StringUtils.isBlank(tmpPath)) {
        throw new RdosDefineException(ErrorCode.DATA_NOT_FIND);
    }
    String hdfsFileName = String.format("%s_%s_%s", tenantId, resourceName, originalFilename);
    String hdfsPath = this.getBatchHdfsPath(tenantId, hdfsFileName);
    try {
        HdfsOperator.uploadLocalFileToHdfs(HadoopConf.getConfiguration(tenantId), HadoopConf.getHadoopKerberosConf(tenantId), tmpPath, hdfsPath);
    } catch (Exception e) {
        throw new RdosDefineException(ErrorCode.SERVER_EXCEPTION, e);
    } finally {
        File tmpFile = new File(tmpPath);
        if (tmpFile.exists()) {
            tmpFile.delete();
        }
    }
    return hdfsPath;
}
Also used : RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) File(java.io.File) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException)

Aggregations

RdosDefineException (com.dtstack.taier.common.exception.RdosDefineException)176 JSONObject (com.alibaba.fastjson.JSONObject)80 IOException (java.io.IOException)24 ArrayList (java.util.ArrayList)20 EComponentType (com.dtstack.taier.common.enums.EComponentType)18 List (java.util.List)18 JSONArray (com.alibaba.fastjson.JSONArray)17 File (java.io.File)16 DtCenterDefException (com.dtstack.taier.common.exception.DtCenterDefException)15 Transactional (org.springframework.transaction.annotation.Transactional)15 BatchTask (com.dtstack.taier.dao.domain.BatchTask)14 ScheduleJob (com.dtstack.taier.dao.domain.ScheduleJob)13 Map (java.util.Map)13 ISourceDTO (com.dtstack.dtcenter.loader.dto.source.ISourceDTO)10 Component (com.dtstack.taier.dao.domain.Component)10 Resource (com.dtstack.taier.dao.dto.Resource)10 HashMap (java.util.HashMap)10 CollectionUtils (org.apache.commons.collections.CollectionUtils)10 ErrorCode (com.dtstack.taier.common.exception.ErrorCode)9 BatchCatalogue (com.dtstack.taier.dao.domain.BatchCatalogue)9