Search in sources :

Example 21 with TaskModel

use of com.bonree.brfs.schedulers.task.model.TaskModel in project BRFS by zhangnianli.

the class DefaultReleaseTask method queryTaskState.

@Override
public int queryTaskState(String taskName, String taskType) {
    try {
        if (BrStringUtils.isEmpty(taskName)) {
            return -1;
        }
        if (BrStringUtils.isEmpty(taskType)) {
            return -2;
        }
        StringBuilder taskPath = new StringBuilder();
        taskPath.append(this.taskQueue).append("/").append(taskType).append("/").append(taskName);
        String path = taskPath.toString();
        if (!client.checkExists(path)) {
            return -3;
        }
        byte[] data = client.getData(path);
        if (data == null || data.length == 0) {
            return -4;
        }
        TaskModel tmp = JsonUtils.toObject(data, TaskModel.class);
        return tmp.getTaskState();
    } catch (Exception e) {
        LOG.error("query task status error {}", e);
    }
    return -5;
}
Also used : TaskModel(com.bonree.brfs.schedulers.task.model.TaskModel)

Aggregations

TaskModel (com.bonree.brfs.schedulers.task.model.TaskModel)21 AtomTaskModel (com.bonree.brfs.schedulers.task.model.AtomTaskModel)11 MetaTaskManagerInterface (com.bonree.brfs.schedulers.task.manager.MetaTaskManagerInterface)7 ManagerContralFactory (com.bonree.brfs.schedulers.ManagerContralFactory)6 TaskServerNodeModel (com.bonree.brfs.schedulers.task.model.TaskServerNodeModel)5 StorageRegion (com.bonree.brfs.duplication.storageregion.StorageRegion)4 HashMap (java.util.HashMap)4 Pair (com.bonree.brfs.common.utils.Pair)3 TaskTypeModel (com.bonree.brfs.schedulers.task.model.TaskTypeModel)3 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 JobDataMap (org.quartz.JobDataMap)3 ServiceManager (com.bonree.brfs.common.service.ServiceManager)2 TaskType (com.bonree.brfs.common.task.TaskType)2 StorageRegionManager (com.bonree.brfs.duplication.storageregion.StorageRegionManager)2 TaskResultModel (com.bonree.brfs.schedulers.task.model.TaskResultModel)2 BRFSTimeFilter (com.bonree.brfs.common.files.impl.BRFSTimeFilter)1 Service (com.bonree.brfs.common.service.Service)1 TaskState (com.bonree.brfs.common.task.TaskState)1 JsonException (com.bonree.brfs.common.utils.JsonUtils.JsonException)1