use of com.bonree.brfs.schedulers.task.model.BatchAtomModel in project BRFS by zhangnianli.
the class CopyRecovery method recoveryDirs.
/**
* 概述:修复目录
* @param content
* @param zkHosts
* @param baseRoutesPath
* @return
* @user <a href=mailto:zhucg@bonree.com>朱成岗</a>
*/
public static TaskResultModel recoveryDirs(String content, String zkHosts, String baseRoutesPath, String dataPath) {
TaskResultModel result = new TaskResultModel();
BatchAtomModel batch = converStringToBatch(content);
if (batch == null) {
result.setSuccess(false);
LOG.debug("batch is empty");
return result;
}
List<AtomTaskModel> atoms = batch.getAtoms();
if (atoms == null || atoms.isEmpty()) {
result.setSuccess(true);
LOG.debug(" files is empty");
return result;
}
ManagerContralFactory mcf = ManagerContralFactory.getInstance();
ServerIDManager sim = mcf.getSim();
ServiceManager sm = mcf.getSm();
StorageRegionManager snm = mcf.getSnm();
CuratorClient curatorClient = mcf.getClient();
StorageRegion sn;
SecondIDParser parser;
String snName;
int snId;
AtomTaskResultModel atomR;
List<String> errors;
for (AtomTaskModel atom : atoms) {
atomR = new AtomTaskResultModel();
atomR.setFiles(atom.getFiles());
atomR.setSn(atom.getStorageName());
snName = atom.getStorageName();
sn = snm.findStorageRegionByName(snName);
if (sn == null) {
atomR.setSuccess(false);
result.setSuccess(false);
result.add(atomR);
LOG.debug("sn == null snName :{}", snName);
continue;
}
snId = sn.getId();
parser = new SecondIDParser(curatorClient, snId, baseRoutesPath);
parser.updateRoute();
errors = recoveryFiles(sm, sim, parser, sn, atom, dataPath);
if (errors == null || errors.isEmpty()) {
result.add(atomR);
LOG.debug("result is empty snName:{}", snName);
continue;
}
atomR.addAll(errors);
atomR.setSuccess(false);
result.setSuccess(false);
}
return result;
}
Aggregations