use of org.smartdata.model.BackUpInfo in project SSM by Intel-bigdata.
the class TestBackUpInfoDao method testInsertAndGetSingleRecord.
@Test
public void testInsertAndGetSingleRecord() {
BackUpInfo backUpInfo = new BackUpInfo();
backUpInfo.setRid(1);
backUpInfo.setPeriod(1);
backUpInfo.setDest("");
backUpInfo.setSrc("");
backUpInfoDao.insert(backUpInfo);
Assert.assertTrue(backUpInfoDao.getByRid(1).equals(backUpInfo));
}
use of org.smartdata.model.BackUpInfo in project SSM by Intel-bigdata.
the class TestBackUpInfoDao method testDelete.
@Test
public void testDelete() {
backUpInfoDao.delete(1L);
BackUpInfo[] backUpInfos = new BackUpInfo[2];
backUpInfos[0] = new BackUpInfo(1, "test", "test", 1);
backUpInfos[1] = new BackUpInfo(2, "test", "test", 1);
backUpInfoDao.insert(backUpInfos);
backUpInfoDao.delete(1L);
Assert.assertTrue(backUpInfoDao.getByRid(2).equals(backUpInfos[1]));
try {
backUpInfoDao.getByRid(1);
} catch (EmptyResultDataAccessException e) {
}
}
use of org.smartdata.model.BackUpInfo in project SSM by Intel-bigdata.
the class TestMetaStore method testInsertAndListAllBackUpInfo.
@Test
public void testInsertAndListAllBackUpInfo() throws MetaStoreException {
BackUpInfo backUpInfo1 = new BackUpInfo(1, "test1", "test1", 1);
BackUpInfo backUpInfo2 = new BackUpInfo(2, "test2", "test2", 2);
BackUpInfo backUpInfo3 = new BackUpInfo(3, "test3", "test3", 3);
metaStore.insertBackUpInfo(backUpInfo1);
metaStore.insertBackUpInfo(backUpInfo2);
metaStore.insertBackUpInfo(backUpInfo3);
List<BackUpInfo> backUpInfos = metaStore.listAllBackUpInfo();
Assert.assertTrue(backUpInfos.get(0).equals(backUpInfo1));
Assert.assertTrue(backUpInfos.get(1).equals(backUpInfo2));
Assert.assertTrue(backUpInfos.get(2).equals(backUpInfo3));
}
use of org.smartdata.model.BackUpInfo in project SSM by Intel-bigdata.
the class FileCopyDrPlugin method onNewRuleExecutor.
public void onNewRuleExecutor(final RuleInfo ruleInfo, TranslateResult tResult) {
long ruleId = ruleInfo.getId();
List<String> pathsCheckGlob = tResult.getGlobPathCheck();
if (pathsCheckGlob.size() == 0) {
pathsCheckGlob = Arrays.asList("/*");
}
List<String> pathsCheck = getPathMatchesList(pathsCheckGlob);
String dirs = StringUtil.join(",", pathsCheck);
CmdletDescriptor des = tResult.getCmdDescriptor();
for (int i = 0; i < des.getActionSize(); i++) {
if (des.getActionName(i).equals("sync")) {
List<String> statements = tResult.getSqlStatements();
String before = statements.get(statements.size() - 1);
String after = before.replace(";", " UNION " + referenceNonExists(tResult, pathsCheck));
statements.set(statements.size() - 1, after);
BackUpInfo backUpInfo = new BackUpInfo();
backUpInfo.setRid(ruleId);
backUpInfo.setSrc(dirs);
String dest = des.getActionArgs(i).get(SyncAction.DEST);
if (!dest.endsWith("/")) {
dest += "/";
des.addActionArg(i, SyncAction.DEST, dest);
}
backUpInfo.setDest(dest);
backUpInfo.setPeriod(tResult.getTbScheduleInfo().getMinimalEvery());
des.addActionArg(i, SyncAction.SRC, dirs);
LOG.debug("Rule executor added for sync rule {} src={} dest={}", ruleInfo, dirs, dest);
synchronized (backups) {
if (!backups.containsKey(ruleId)) {
backups.put(ruleId, new LinkedList<BackUpInfo>());
}
}
List<BackUpInfo> infos = backups.get(ruleId);
synchronized (infos) {
try {
metaStore.deleteBackUpInfo(ruleId);
// Add base Sync tag
FileDiff fileDiff = new FileDiff(FileDiffType.BASESYNC);
fileDiff.setSrc(backUpInfo.getSrc());
fileDiff.getParameters().put("-dest", backUpInfo.getDest());
metaStore.insertFileDiff(fileDiff);
metaStore.insertBackUpInfo(backUpInfo);
infos.add(backUpInfo);
} catch (MetaStoreException e) {
LOG.error("Insert backup info error:" + backUpInfo, e);
}
}
break;
}
}
}
use of org.smartdata.model.BackUpInfo in project SSM by Intel-bigdata.
the class MetaStore method srcInbackup.
public boolean srcInbackup(String src) throws MetaStoreException {
if (setBackSrc == null) {
setBackSrc = new HashSet<>();
List<BackUpInfo> backUpInfos = listAllBackUpInfo();
for (BackUpInfo backUpInfo : backUpInfos) {
setBackSrc.add(backUpInfo.getSrc());
}
}
// LOG.info("Backup src = {}, setBackSrc {}", src, setBackSrc);
for (String srcDir : setBackSrc) {
if (src.startsWith(srcDir)) {
return true;
}
}
return false;
}
Aggregations