use of com.bonree.brfs.schedulers.task.model.TaskServerNodeModel in project BRFS by zhangnianli.
the class TaskStateLifeContral method getCurrentOperationTask.
/**
* 概述:获取当前任务信息
* @param release
* @param typeName
* @param serverId
* @param limitCount
* @return
* @user <a href=mailto:zhucg@bonree.com>朱成岗</a>
*/
public static Pair<String, TaskModel> getCurrentOperationTask(MetaTaskManagerInterface release, String typeName, String serverId, int limitCount) {
List<Pair<String, Pair<Integer, Integer>>> needTasks = getServerState(release, typeName, serverId);
Pair<String, Pair<Integer, Integer>> task = getOperationTask(needTasks, limitCount);
if (task == null) {
return null;
}
if (BrStringUtils.isEmpty(task.getFirst())) {
return null;
}
TaskModel cTask = release.getTaskContentNodeInfo(typeName, task.getFirst());
if (cTask == null) {
return null;
}
// 更新异常的次数
if (task.getSecond().getFirst() == TaskState.EXCEPTION.code()) {
TaskServerNodeModel server = release.getTaskServerContentNodeInfo(typeName, task.getFirst(), serverId);
LOG.debug("TaskMessage get sTask :{}", JsonUtils.toJsonStringQuietly(server));
server.setRetryCount(server.getRetryCount() + 1);
release.updateServerTaskContentNode(serverId, task.getFirst(), typeName, server);
}
return new Pair<>(task.getFirst(), cTask);
}
use of com.bonree.brfs.schedulers.task.model.TaskServerNodeModel in project BRFS by zhangnianli.
the class DefaultReleaseTask method changeTaskServerNodeContentState.
@Override
public boolean changeTaskServerNodeContentState(String taskName, String taskType, String serverId, int taskState) {
try {
if (BrStringUtils.isEmpty(taskName)) {
return false;
}
if (BrStringUtils.isEmpty(taskType)) {
return false;
}
if (BrStringUtils.isEmpty(serverId)) {
return false;
}
TaskServerNodeModel tmp = getTaskServerContentNodeInfo(taskType, taskName, serverId);
if (tmp == null) {
return false;
}
tmp.setTaskState(taskState);
updateServerTaskContentNode(serverId, taskName, taskType, tmp);
return true;
} catch (Exception e) {
LOG.error("change task server node cotent error {}", e);
}
return false;
}
Aggregations