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;
}
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;
}
Aggregations