Search in sources :

Example 11 with TaskServerNodeModel

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);
}
Also used : TaskServerNodeModel(com.bonree.brfs.schedulers.task.model.TaskServerNodeModel) TaskModel(com.bonree.brfs.schedulers.task.model.TaskModel) AtomTaskModel(com.bonree.brfs.schedulers.task.model.AtomTaskModel)

Example 12 with TaskServerNodeModel

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;
}
Also used : TaskServerNodeModel(com.bonree.brfs.schedulers.task.model.TaskServerNodeModel)

Aggregations

TaskServerNodeModel (com.bonree.brfs.schedulers.task.model.TaskServerNodeModel)12 TaskModel (com.bonree.brfs.schedulers.task.model.TaskModel)5 AtomTaskModel (com.bonree.brfs.schedulers.task.model.AtomTaskModel)4 ManagerContralFactory (com.bonree.brfs.schedulers.ManagerContralFactory)2 MetaTaskManagerInterface (com.bonree.brfs.schedulers.task.manager.MetaTaskManagerInterface)2 ArrayList (java.util.ArrayList)2 TaskState (com.bonree.brfs.common.task.TaskState)1 Pair (com.bonree.brfs.common.utils.Pair)1 AtomTaskResultModel (com.bonree.brfs.schedulers.task.model.AtomTaskResultModel)1 TaskResultModel (com.bonree.brfs.schedulers.task.model.TaskResultModel)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1