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;
}
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);
}
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();
}
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();
}
Aggregations