use of org.smartdata.model.BackUpInfo in project SSM by Intel-bigdata.
the class InotifyEventApplier method insertDeleteDiff.
private void insertDeleteDiff(String path) throws MetaStoreException {
// TODO: remove "/" appended in src or dest in backup_file table
String pathWithSlash = path.endsWith("/") ? path : path + "/";
if (inBackup(pathWithSlash)) {
List<BackUpInfo> backUpInfos = metaStore.getBackUpInfoBySrc(pathWithSlash);
for (BackUpInfo backUpInfo : backUpInfos) {
String destPath = pathWithSlash.replaceFirst(backUpInfo.getSrc(), backUpInfo.getDest());
try {
// tackle root path case
URI namenodeUri = new URI(destPath);
String root = "hdfs://" + namenodeUri.getHost() + ":" + String.valueOf(namenodeUri.getPort());
if (destPath.equals(root) || destPath.equals(root + "/") || destPath.equals("/")) {
for (String srcFilePath : getFilesUnderDir(pathWithSlash)) {
FileDiff fileDiff = new FileDiff(FileDiffType.DELETE);
fileDiff.setSrc(srcFilePath);
String destFilePath = srcFilePath.replaceFirst(backUpInfo.getSrc(), backUpInfo.getDest());
fileDiff.getParameters().put("-dest", destFilePath);
metaStore.insertFileDiff(fileDiff);
}
} else {
FileDiff fileDiff = new FileDiff(FileDiffType.DELETE);
// use the path getting from event with no slash appended
fileDiff.setSrc(path);
// put sync's dest path in parameter for delete use
fileDiff.getParameters().put("-dest", destPath);
metaStore.insertFileDiff(fileDiff);
}
} catch (URISyntaxException e) {
LOG.error("Error occurs!", e);
}
}
}
}
use of org.smartdata.model.BackUpInfo in project SSM by Intel-bigdata.
the class TestAlluxioEntryApplier method testSetAttributeApplier.
@Test
public void testSetAttributeApplier() throws Exception {
FileSystem fs = Mockito.mock(FileSystem.class);
AlluxioEntryApplier entryApplier = new AlluxioEntryApplier(metaStore, fs);
FileInfo fooFile = FileInfo.newBuilder().setFileId(33554431).setIsdir(false).setPath("/foo/foobar").build();
metaStore.insertFile(fooFile);
BackUpInfo backUpInfo = new BackUpInfo(1L, "/foo/foobar", "remote/dest/", 10);
metaStore.insertBackUpInfo(backUpInfo);
alluxio.wire.FileInfo info1 = new alluxio.wire.FileInfo().setFileId(33554431).setPath("/foo/foobar").setLength(100L).setFolder(false).setBlockSizeBytes(210000).setLastModificationTimeMs(1515665470681L).setCreationTimeMs(1515665470681L).setMode(493).setOwner("user1").setGroup("group1");
URIStatus status1 = new URIStatus(info1);
Mockito.when(fs.getStatus(new AlluxioURI("/foo/foobar"))).thenReturn(status1);
SetAttributeEntry setAttributeEntry = SetAttributeEntry.newBuilder().setId(33554431).setOpTimeMs(1515667208590658L).setPermission(511).build();
JournalEntry setAttributeJEntry = JournalEntry.newBuilder().setSetAttribute(setAttributeEntry).build();
entryApplier.apply(setAttributeJEntry);
List<FileDiff> fileDiffs = metaStore.getFileDiffsByFileName("/foo/foobar");
Assert.assertTrue(fileDiffs.size() > 0);
for (FileDiff fileDiff : fileDiffs) {
if (fileDiff.getDiffType().equals(FileDiffType.METADATA)) {
Assert.assertEquals("511", fileDiff.getParameters().get("-permission"));
}
}
}
use of org.smartdata.model.BackUpInfo in project SSM by Intel-bigdata.
the class TestMetaStore method testDeleteBackUpInfo.
@Test
public void testDeleteBackUpInfo() throws MetaStoreException {
BackUpInfo backUpInfo1 = new BackUpInfo(1, "test1", "test1", 1);
metaStore.insertBackUpInfo(backUpInfo1);
Assert.assertTrue(metaStore.srcInbackup("test1/dfafdsaf"));
Assert.assertFalse(metaStore.srcInbackup("test2"));
metaStore.deleteBackUpInfo(1);
Assert.assertTrue(metaStore.listAllBackUpInfo().size() == 0);
metaStore.insertBackUpInfo(backUpInfo1);
metaStore.deleteAllBackUpInfo();
Assert.assertTrue(metaStore.listAllBackUpInfo().size() == 0);
}
use of org.smartdata.model.BackUpInfo in project SSM by Intel-bigdata.
the class TestMetaStore method testGetBackUpInfoById.
@Test
public void testGetBackUpInfoById() throws MetaStoreException {
BackUpInfo backUpInfo1 = new BackUpInfo(1, "test1", "test1", 1);
metaStore.insertBackUpInfo(backUpInfo1);
Assert.assertTrue(metaStore.getBackUpInfo(1).equals(backUpInfo1));
}
use of org.smartdata.model.BackUpInfo in project SSM by Intel-bigdata.
the class TestBackUpInfoDao method testUpdate.
@Test
public void testUpdate() {
BackUpInfo backUpInfo = new BackUpInfo();
backUpInfo.setRid(1);
backUpInfo.setSrc("test");
backUpInfo.setDest("test");
backUpInfo.setPeriod(1);
backUpInfoDao.insert(backUpInfo);
backUpInfoDao.update(1, 2);
backUpInfo.setPeriod(2);
Assert.assertTrue(backUpInfoDao.getByRid(1).equals(backUpInfo));
}
Aggregations