Search in sources :

Example 6 with JudgeResult

use of com.dtstack.taier.pluginapi.pojo.JudgeResult in project Taier by DTStack.

the class FlinkClient method judgeSlots.

@Override
public JudgeResult judgeSlots(JobClient jobClient) {
    ClusterMode clusterMode = ClusterMode.getClusteMode(flinkConfig.getClusterMode());
    boolean isPerJob = ClusterMode.isPerjob(clusterMode);
    JudgeResult judgeResult = JudgeResult.notOk(null);
    try {
        if (ClusterMode.isStandalone(clusterMode)) {
            return judgeSessionSlot(jobClient, true);
        }
        judgeResult = KerberosUtils.login(flinkConfig, () -> {
            FlinkPerJobResourceInfo perJobResourceInfo = FlinkPerJobResourceInfo.FlinkPerJobResourceInfoBuilder().withYarnClient(flinkClientBuilder.getYarnClient()).withQueueName(flinkConfig.getQueue()).withYarnAccepterTaskNumber(flinkConfig.getYarnAccepterTaskNumber()).build();
            return perJobResourceInfo.judgeSlots(jobClient);
        }, hadoopConf.getYarnConfiguration());
        if (judgeResult.available() && !isPerJob) {
            judgeResult = judgeSessionSlot(jobClient, false);
        }
    } catch (Exception e) {
        logger.error("taskId:{} judgeSlots error: ", jobClient.getJobId(), e);
        judgeResult = JudgeResult.exception("judgeSlots error:" + ExceptionUtil.getErrorMessage(e));
    }
    logger.info("taskId:{}, judgeResult: {}, reason: {}", jobClient.getJobId(), judgeResult.getResult(), judgeResult.getReason());
    return judgeResult;
}
Also used : ClusterMode(com.dtstack.taier.flink.base.enums.ClusterMode) FlinkPerJobResourceInfo(com.dtstack.taier.flink.resource.FlinkPerJobResourceInfo) JudgeResult(com.dtstack.taier.pluginapi.pojo.JudgeResult) IOException(java.io.IOException) PluginDefineException(com.dtstack.taier.pluginapi.exception.PluginDefineException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) MalformedURLException(java.net.MalformedURLException)

Example 7 with JudgeResult

use of com.dtstack.taier.pluginapi.pojo.JudgeResult in project Taier by DTStack.

the class FlinkPerJobResourceInfo method judgePerjobResource.

private JudgeResult judgePerjobResource(JobClient jobClient) {
    JudgeResult jr = getYarnSlots(yarnClient, queueName, yarnAccepterTaskNumber);
    if (!jr.available()) {
        return jr;
    }
    setTaskResourceInfo(jobClient);
    List<InstanceInfo> instanceInfos = Lists.newArrayList(// 作为启动 am 和 jobmanager
    InstanceInfo.newRecord(1, 1, jobmanagerMemoryMb), InstanceInfo.newRecord(numberTaskManagers, slotsPerTaskManager, taskmanagerMemoryMb));
    return judgeYarnResource(instanceInfos);
}
Also used : JudgeResult(com.dtstack.taier.pluginapi.pojo.JudgeResult)

Example 8 with JudgeResult

use of com.dtstack.taier.pluginapi.pojo.JudgeResult in project Taier by DTStack.

the class AbstractK8sResourceInfo method judgeResource.

protected JudgeResult judgeResource(List<InstanceInfo> instanceInfos) {
    if (totalFreeCore == 0 || totalFreeMem == 0) {
        logger.info("judgeResource, totalFreeCore={}, totalFreeMem={}", totalFreeCore, totalFreeMem);
        return JudgeResult.notOk("totalFreeCore or totalFreeMem is 0");
    }
    double needTotalCore = 0;
    double needTotalMem = 0;
    for (InstanceInfo instanceInfo : instanceInfos) {
        needTotalCore += instanceInfo.instances * instanceInfo.coresPerInstance;
        needTotalMem += instanceInfo.instances * instanceInfo.memPerInstance;
    }
    if (needTotalCore == 0 || needTotalMem == 0) {
        return JudgeResult.limitError("task resource configuration error,needTotalCore:" + 0 + ", needTotalMem:" + needTotalMem);
    }
    if (needTotalCore > totalCore) {
        logger.info("judgeResource, needTotalCore={}, totalCore={}", needTotalCore, totalCore);
        return JudgeResult.limitError("The task required core resources are greater than the total resources");
    }
    if (needTotalMem > totalMem) {
        logger.info("judgeResource, needTotalMem={}, totalMem={}", needTotalMem, totalMem);
        return JudgeResult.limitError("The task required memory resources are greater than the total resources");
    }
    for (InstanceInfo instanceInfo : instanceInfos) {
        JudgeResult judgeInstanceResource = judgeInstanceResource(instanceInfo.instances, instanceInfo.coresPerInstance, instanceInfo.memPerInstance);
        if (!judgeInstanceResource.available()) {
            logger.info("judgeResource, nmFreeCore={}, nmFreeMem={} instanceInfo={}", nmFreeCore, nmFreeMem, instanceInfo);
            return judgeInstanceResource;
        }
    }
    return JudgeResult.ok();
}
Also used : JudgeResult(com.dtstack.taier.pluginapi.pojo.JudgeResult)

Example 9 with JudgeResult

use of com.dtstack.taier.pluginapi.pojo.JudgeResult in project Taier by DTStack.

the class AbstractYarnResourceInfo method judgeYarnResource.

protected JudgeResult judgeYarnResource(List<InstanceInfo> instanceInfos) {
    if (totalFreeCore == 0 || totalFreeMem == 0) {
        logger.info("judgeYarnResource, totalFreeCore={}, totalFreeMem={}", totalFreeCore, totalFreeMem);
        return JudgeResult.notOk("totalFreeCore or totalFreeMem is 0");
    }
    int needTotalCore = 0;
    int needTotalMem = 0;
    for (InstanceInfo instanceInfo : instanceInfos) {
        if (instanceInfo.coresPerInstance > containerCoreMax) {
            logger.info("judgeYarnResource, containerCoreMax={}, coresPerInstance={}", containerCoreMax, instanceInfo.coresPerInstance);
            return JudgeResult.notOk("the instance's per core larger than then maximum containerCore");
        }
        if (instanceInfo.memPerInstance > containerMemoryMax) {
            logger.info("judgeYarnResource, containerMemoryMax={}, memPerInstance={}", containerMemoryMax, instanceInfo.memPerInstance);
            return JudgeResult.notOk("the instance's per memory larger than then maximum containerMemory");
        }
        needTotalCore += instanceInfo.instances * instanceInfo.coresPerInstance;
        needTotalMem += instanceInfo.instances * instanceInfo.memPerInstance;
    }
    if (needTotalCore == 0 || needTotalMem == 0) {
        return JudgeResult.limitError("Yarn task resource configuration error,needTotalCore:" + 0 + ", needTotalMem:" + needTotalMem);
    }
    if (needTotalCore > (totalCore * queueCapacity)) {
        return JudgeResult.limitError("The Yarn task is set to a core larger than the maximum allocated core");
    }
    if (needTotalMem > (totalMem * queueCapacity)) {
        return JudgeResult.limitError("The Yarn task is set to a mem larger than the maximum allocated mem");
    }
    if (needTotalCore > (totalCore * capacity)) {
        logger.info("judgeYarnResource, needTotalCore={}, totalCore={}, capacity={}", needTotalCore, totalCore, capacity);
        return JudgeResult.notOk("The task required core resources are greater than the total queue resources");
    }
    if (needTotalMem > (totalMem * capacity)) {
        logger.info("judgeYarnResource, needTotalMem={}, totalMem={}, capacity={}", needTotalMem, totalMem, capacity);
        return JudgeResult.notOk("The task required memory resources are greater than the total queue resources");
    }
    for (InstanceInfo instanceInfo : instanceInfos) {
        JudgeResult judgeInstanceResource = judgeInstanceResource(instanceInfo.instances, instanceInfo.coresPerInstance, instanceInfo.memPerInstance);
        if (!judgeInstanceResource.available()) {
            logger.info("judgeYarnResource, nmFreeCore={}, nmFreeMem={} instanceInfo={}", nmFreeCore, nmFreeMem, instanceInfo);
            return judgeInstanceResource;
        }
    }
    return JudgeResult.ok();
}
Also used : JudgeResult(com.dtstack.taier.pluginapi.pojo.JudgeResult)

Aggregations

JudgeResult (com.dtstack.taier.pluginapi.pojo.JudgeResult)9 JobClient (com.dtstack.taier.pluginapi.JobClient)2 IOException (java.io.IOException)2 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)2 Test (org.junit.Test)2 EngineResourceInfo (com.dtstack.taier.base.resource.EngineResourceInfo)1 ClientAccessException (com.dtstack.taier.common.exception.ClientAccessException)1 RdosDefineException (com.dtstack.taier.common.exception.RdosDefineException)1 WorkerAccessException (com.dtstack.taier.common.exception.WorkerAccessException)1 ClusterMode (com.dtstack.taier.flink.base.enums.ClusterMode)1 FlinkPerJobResourceInfo (com.dtstack.taier.flink.resource.FlinkPerJobResourceInfo)1 ClientArgumentException (com.dtstack.taier.pluginapi.exception.ClientArgumentException)1 PluginDefineException (com.dtstack.taier.pluginapi.exception.PluginDefineException)1 JobResult (com.dtstack.taier.pluginapi.pojo.JobResult)1 RdbsExeQueue (com.dtstack.taier.rdbs.common.executor.RdbsExeQueue)1 Lists (com.google.common.collect.Lists)1 MalformedURLException (java.net.MalformedURLException)1 EnumSet (java.util.EnumSet)1 List (java.util.List)1 Properties (java.util.Properties)1