Search in sources :

Example 11 with AtomTaskModel

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

the class TaskStateLifeContral method changeRunTaskModel.

public static TaskModel changeRunTaskModel(final TaskModel message, String dataPath) {
    if (message == null) {
        return null;
    }
    // 文件恢复单独不需要处理
    TaskModel changeTask = new TaskModel();
    changeTask.setCreateTime(message.getCreateTime());
    changeTask.setTaskState(changeTask.getTaskState());
    changeTask.setTaskType(message.getTaskType());
    if (TaskType.SYSTEM_COPY_CHECK.code() == changeTask.getTaskType()) {
        changeTask.setAtomList(message.getAtomList());
        return changeTask;
    }
    // 删除任务,校验任务,需要扫目录确定
    List<AtomTaskModel> mAtoms = message.getAtomList();
    if (mAtoms == null || mAtoms.isEmpty()) {
        LOG.warn("task message atom list is empty!!!");
        return null;
    }
    // 循环atom,封装atom
    AtomTaskModel rAtom;
    long startTime;
    long endTime;
    String snName;
    int partNum;
    Map<String, String> map;
    long granule;
    for (AtomTaskModel atom : mAtoms) {
        startTime = TimeUtils.getMiles(atom.getDataStartTime(), TimeUtils.TIME_MILES_FORMATE);
        endTime = TimeUtils.getMiles(atom.getDataStopTime(), TimeUtils.TIME_MILES_FORMATE);
        snName = atom.getStorageName();
        partNum = atom.getPatitionNum();
        granule = atom.getGranule();
        map = new HashMap<>();
        map.put(BRFSPath.STORAGEREGION, snName);
        List<BRFSPath> dirPaths = BRFSFileUtil.scanBRFSFiles(dataPath, map, map.size(), new BRFSTimeFilter(startTime, endTime));
        if (dirPaths == null || dirPaths.isEmpty()) {
            LOG.debug("It's no dir to take task [{}]:[{}]-[{}]", snName, TimeUtils.timeInterval(startTime, granule), TimeUtils.timeInterval(endTime, granule));
            continue;
        }
        List<Long> times = filterRepeatDirs(dirPaths);
        for (Long time : times) {
            rAtom = AtomTaskModel.getInstance(null, snName, atom.getTaskOperation(), partNum, time, time + atom.getGranule(), 0);
            changeTask.addAtom(rAtom);
        }
    }
    return changeTask;
}
Also used : BRFSTimeFilter(com.bonree.brfs.common.files.impl.BRFSTimeFilter) TaskModel(com.bonree.brfs.schedulers.task.model.TaskModel) AtomTaskModel(com.bonree.brfs.schedulers.task.model.AtomTaskModel) AtomTaskModel(com.bonree.brfs.schedulers.task.model.AtomTaskModel)

Example 12 with AtomTaskModel

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

the class TaskStateLifeContral method changeRunTaskModel.

/**
 * 概述:将任务分批
 * @param message
 * @return
 * @user <a href=mailto:zhucg@bonree.com>朱成岗</a>
 */
@Deprecated
public static TaskModel changeRunTaskModel(final TaskModel message) {
    if (message == null) {
        return null;
    }
    TaskModel changeTask = new TaskModel();
    changeTask.setCreateTime(message.getCreateTime());
    changeTask.setTaskState(changeTask.getTaskState());
    changeTask.setTaskType(message.getTaskType());
    if (TaskType.SYSTEM_COPY_CHECK.code() == changeTask.getTaskType()) {
        changeTask.setAtomList(message.getAtomList());
        return changeTask;
    }
    List<AtomTaskModel> atoms = message.getAtomList();
    AtomTaskModel atom;
    if (atoms == null || atoms.isEmpty()) {
        return changeTask;
    }
    long startTime;
    long endTime;
    String snName;
    String operation;
    long granule;
    for (AtomTaskModel aTask : atoms) {
        startTime = TimeUtils.getMiles(aTask.getDataStartTime(), TimeUtils.TIME_MILES_FORMATE);
        endTime = TimeUtils.getMiles(aTask.getDataStopTime(), TimeUtils.TIME_MILES_FORMATE);
        snName = aTask.getStorageName();
        operation = aTask.getTaskOperation();
        granule = aTask.getGranule();
        for (long start = startTime; start < endTime; start += granule) {
            if (start + granule > endTime) {
                continue;
            }
            atom = AtomTaskModel.getInstance(null, snName, operation, aTask.getPatitionNum(), start, start + granule, granule);
            changeTask.addAtom(atom);
        }
    }
    return changeTask;
}
Also used : TaskModel(com.bonree.brfs.schedulers.task.model.TaskModel) AtomTaskModel(com.bonree.brfs.schedulers.task.model.AtomTaskModel) AtomTaskModel(com.bonree.brfs.schedulers.task.model.AtomTaskModel)

Aggregations

AtomTaskModel (com.bonree.brfs.schedulers.task.model.AtomTaskModel)12 TaskModel (com.bonree.brfs.schedulers.task.model.TaskModel)6 AtomTaskResultModel (com.bonree.brfs.schedulers.task.model.AtomTaskResultModel)5 BatchAtomModel (com.bonree.brfs.schedulers.task.model.BatchAtomModel)5 TaskResultModel (com.bonree.brfs.schedulers.task.model.TaskResultModel)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)4 StorageRegion (com.bonree.brfs.duplication.storageregion.StorageRegion)3 JobDataMap (org.quartz.JobDataMap)3 Pair (com.bonree.brfs.common.utils.Pair)2 BRFSTimeFilter (com.bonree.brfs.common.files.impl.BRFSTimeFilter)1 ServiceManager (com.bonree.brfs.common.service.ServiceManager)1 CuratorClient (com.bonree.brfs.common.zookeeper.curator.CuratorClient)1 StorageRegionManager (com.bonree.brfs.duplication.storageregion.StorageRegionManager)1 SecondIDParser (com.bonree.brfs.rebalance.route.SecondIDParser)1 ManagerContralFactory (com.bonree.brfs.schedulers.ManagerContralFactory)1 TaskServerNodeModel (com.bonree.brfs.schedulers.task.model.TaskServerNodeModel)1 ServerIDManager (com.bonree.brfs.server.identification.ServerIDManager)1 Map (java.util.Map)1