use of com.vip.saturn.job.console.domain.ExecutorProvided in project Saturn by vipshop.
the class DashboardServiceImpl method isUnableFailoverJob.
// 无法高可用的情况:
// 1、勾选只使用优先executor,preferList只有一个物理机器(剔除offline、deleted的物理机)
// 2、没有勾选只使用优先executor,没有选择容器资源,可供选择的preferList只有一个物理机器(剔除offline、deleted的物理机,剔除容器资源)
private AbnormalJob isUnableFailoverJob(CuratorFramework curatorClient, AbnormalJob unableFailoverJob, CuratorFrameworkOp curatorFrameworkOp) {
try {
String jobName = unableFailoverJob.getJobName();
String preferList = getData(curatorClient, JobNodePath.getConfigNodePath(jobName, "preferList"));
Boolean onlyUsePreferList = !Boolean.valueOf(getData(curatorClient, JobNodePath.getConfigNodePath(jobName, "useDispreferList")));
List<ExecutorProvided> preferListProvided = jobDimensionService.getAllExecutors(jobName, curatorFrameworkOp);
List<String> preferListArr = new ArrayList<>();
if (preferList != null && preferList.trim().length() > 0) {
String[] split = preferList.split(",");
for (String prefer : split) {
String tmp = prefer.trim();
if (tmp.length() > 0) {
if (!preferListArr.contains(tmp)) {
preferListArr.add(tmp);
}
}
}
}
boolean containerSelected = false;
int count = 0;
if (onlyUsePreferList) {
for (ExecutorProvided executorProvided : preferListProvided) {
if (preferListArr.contains(executorProvided.getExecutorName())) {
if (ExecutorProvidedType.DOCKER.equals(executorProvided.getType())) {
containerSelected = true;
break;
} else if (ExecutorProvidedType.ONLINE.equals(executorProvided.getType())) {
count++;
}
}
}
} else {
for (ExecutorProvided executorProvided : preferListProvided) {
if (preferListArr.contains(executorProvided.getExecutorName()) && ExecutorProvidedType.DOCKER.equals(executorProvided.getType())) {
containerSelected = true;
break;
}
if (ExecutorProvidedType.ONLINE.equals(executorProvided.getType())) {
count++;
if (count > 1) {
break;
}
}
}
}
if (!containerSelected && count == 1) {
return unableFailoverJob;
}
return null;
} catch (Exception e) {
log.error(e.getMessage(), e);
return null;
}
}
use of com.vip.saturn.job.console.domain.ExecutorProvided in project Saturn by vipshop.
the class JobController method getAllExecutors.
/**
* 获取所有的executor作为优先候选列表
*/
@RequestMapping(value = "getAllExecutors", method = RequestMethod.GET)
public RequestResult getAllExecutors(String jobName) {
RequestResult requestResult = new RequestResult();
try {
List<ExecutorProvided> allExecutors = jobDimensionService.getAllExecutors(jobName);
requestResult.setObj(allExecutors);
requestResult.setSuccess(true);
} catch (Exception e) {
requestResult.setSuccess(false);
requestResult.setMessage(e.toString());
}
return requestResult;
}
use of com.vip.saturn.job.console.domain.ExecutorProvided in project Saturn by vipshop.
the class JobController method batchSetPreferExecutorsEnabled.
@RequestMapping(value = "batchSetPreferExecutorsEnabled", method = RequestMethod.GET)
public RequestResult batchSetPreferExecutorsEnabled(HttpServletRequest request) {
RequestResult requestResult = new RequestResult();
try {
List<ExecutorProvided> allExecutorsOfNamespace = jobDimensionService.getAllExecutorsOfNamespace();
requestResult.setSuccess(true);
requestResult.setObj(allExecutorsOfNamespace);
} catch (Exception e) {
requestResult.setSuccess(false);
requestResult.setMessage(e.getMessage());
}
return requestResult;
}
Aggregations