use of org.smartdata.model.FileInfo in project SSM by Intel-bigdata.
the class TestAlluxioEntryApplier method testInodeDirectoryApplier.
@Test
public void testInodeDirectoryApplier() throws Exception {
FileSystem fs = Mockito.mock(FileSystem.class);
AlluxioEntryApplier entryApplier = new AlluxioEntryApplier(metaStore, fs);
FileInfo rootDir = FileInfo.newBuilder().setFileId(0).setIsdir(true).setPath("/").build();
metaStore.insertFile(rootDir);
alluxio.wire.FileInfo info1 = new alluxio.wire.FileInfo().setFileId(1).setPath("/dir1").setLength(0L).setFolder(true).setBlockSizeBytes(1000000).setLastModificationTimeMs(1528876616216L).setCreationTimeMs(1528876616216L).setMode(493).setOwner("user1").setGroup("group1");
URIStatus status1 = new URIStatus(info1);
Mockito.when(fs.getStatus(new AlluxioURI("/dir1"))).thenReturn(status1);
InodeDirectoryEntry inodeDirectoryEntry = InodeDirectoryEntry.newBuilder().setId(1).setParentId(0).setName("dir1").setPersistenceState("NOT_PERSISTED").setPinned(false).setCreationTimeMs(1528876616216L).setLastModificationTimeMs(1528876616216L).setOwner("user1").setGroup("group1").setMode(493).setMountPoint(false).setDirectChildrenLoaded(false).setTtl(-1L).setTtlAction(PTtlAction.DELETE).build();
JournalEntry inodeDirectoryJEntry = JournalEntry.newBuilder().setInodeDirectory(inodeDirectoryEntry).build();
entryApplier.apply(inodeDirectoryJEntry);
Assert.assertTrue(metaStore.getFile().get(0).getPath().equals("/"));
Assert.assertTrue(metaStore.getFile().get(1).getPath().equals("/dir1"));
Assert.assertEquals("user1", metaStore.getFile("/dir1").getOwner());
Assert.assertEquals(1528876616216L, metaStore.getFile("/dir1").getModificationTime());
}
use of org.smartdata.model.FileInfo in project SSM by Intel-bigdata.
the class TestAlluxioEntryApplier method testInodeLastMTimeApplier.
@Test
public void testInodeLastMTimeApplier() throws Exception {
FileSystem fs = Mockito.mock(FileSystem.class);
AlluxioEntryApplier entryApplier = new AlluxioEntryApplier(metaStore, fs);
FileInfo fooFile = FileInfo.newBuilder().setFileId(5).setIsdir(true).setPath("/baz").build();
metaStore.insertFile(fooFile);
BackUpInfo backUpInfo = new BackUpInfo(1L, "/baz", "remote/dest/", 10);
metaStore.insertBackUpInfo(backUpInfo);
alluxio.wire.FileInfo info1 = new alluxio.wire.FileInfo().setFileId(5).setPath("/baz").setLength(0L).setFolder(true).setBlockSizeBytes(1000000).setLastModificationTimeMs(1515665470681L).setCreationTimeMs(1515665470681L).setMode(493).setOwner("user1").setGroup("group1");
URIStatus status1 = new URIStatus(info1);
Mockito.when(fs.getStatus(new AlluxioURI("/baz"))).thenReturn(status1);
InodeLastModificationTimeEntry inodeLastMTimeEntry = InodeLastModificationTimeEntry.newBuilder().setId(5).setLastModificationTimeMs(1515667810911L).build();
JournalEntry inodeLastMTimeJEntry = JournalEntry.newBuilder().setInodeLastModificationTime(inodeLastMTimeEntry).build();
entryApplier.apply(inodeLastMTimeJEntry);
List<FileDiff> fileDiffs = metaStore.getFileDiffsByFileName("/baz");
Assert.assertTrue(fileDiffs.size() > 0);
for (FileDiff fileDiff : fileDiffs) {
if (fileDiff.getDiffType().equals(FileDiffType.METADATA)) {
Assert.assertEquals("/baz", fileDiff.getSrc());
Assert.assertEquals("1515667810911", fileDiff.getParameters().get("-mtime"));
}
}
}
use of org.smartdata.model.FileInfo in project SSM by Intel-bigdata.
the class TestAlluxioEntryApplier method testInodeFileApplier.
@Test
public void testInodeFileApplier() throws Exception {
FileSystem fs = Mockito.mock(FileSystem.class);
AlluxioEntryApplier entryApplier = new AlluxioEntryApplier(metaStore, fs);
FileInfo fooDir = FileInfo.newBuilder().setFileId(6).setIsdir(true).setPath("/foo").build();
metaStore.insertFile(fooDir);
BackUpInfo backUpInfo = new BackUpInfo(1L, "/foo/foobar1", "remote/dest/", 10);
metaStore.insertBackUpInfo(backUpInfo);
alluxio.wire.FileInfo info1 = new alluxio.wire.FileInfo().setFileId(33554431).setPath("/foo/foobar1").setLength(10L).setFolder(false).setBlockSizeBytes(536870912).setLastModificationTimeMs(1515665470681L).setCreationTimeMs(1515665470681L).setMode(420).setOwner("user1").setGroup("group1");
URIStatus status1 = new URIStatus(info1);
Mockito.when(fs.getStatus(new AlluxioURI("/foo/foobar1"))).thenReturn(status1);
InodeFileEntry inodeFileEntry = InodeFileEntry.newBuilder().setId(33554431).setParentId(6).setName("foobar1").setPersistenceState("NOT_PERSISTED").setPinned(false).setCreationTimeMs(1515665470681L).setBlockSizeBytes(536870912).setLength(10L).setCompleted(false).setCacheable(true).setTtl(-1L).setOwner("user1").setGroup("group1").setMode(420).setTtlAction(PTtlAction.DELETE).build();
JournalEntry inodeFileJEntry = JournalEntry.newBuilder().setInodeFile(inodeFileEntry).build();
entryApplier.apply(inodeFileJEntry);
Assert.assertEquals(33554431, metaStore.getFile("/foo/foobar1").getFileId());
Assert.assertEquals("user1", metaStore.getFile("/foo/foobar1").getOwner());
Assert.assertEquals(536870912, metaStore.getFile("/foo/foobar1").getBlocksize());
List<FileDiff> fileDiffs = metaStore.getFileDiffsByFileName("/foo/foobar1");
Assert.assertTrue(fileDiffs.size() > 0);
for (FileDiff fileDiff : fileDiffs) {
if (fileDiff.getDiffType().equals(FileDiffType.APPEND)) {
Assert.assertTrue(fileDiff.getParameters().get("-owner").equals("user1"));
Assert.assertTrue(fileDiff.getParameters().get("-mtime").equals("1515665470681"));
Assert.assertTrue(fileDiff.getParameters().get("-length").equals("10"));
}
}
}
use of org.smartdata.model.FileInfo in project SSM by Intel-bigdata.
the class TestAlluxioEntryApplier method testDeleteFileApplier.
@Test
public void testDeleteFileApplier() throws Exception {
FileSystem fs = Mockito.mock(FileSystem.class);
AlluxioEntryApplier entryApplier = new AlluxioEntryApplier(metaStore, fs);
FileInfo fooFile = FileInfo.newBuilder().setFileId(100663295).setIsdir(false).setPath("/foo/foobar_del").build();
metaStore.insertFile(fooFile);
BackUpInfo backUpInfo = new BackUpInfo(1L, "/foo/foobar_del", "remote/dest/", 10);
metaStore.insertBackUpInfo(backUpInfo);
alluxio.wire.FileInfo info1 = new alluxio.wire.FileInfo().setFileId(100663295).setPath("/foo/foobar_del").setLength(500L).setFolder(false).setBlockSizeBytes(510000).setLastModificationTimeMs(1515665270681L).setCreationTimeMs(1515665270681L).setMode(493).setOwner("user1").setGroup("group1");
URIStatus status1 = new URIStatus(info1);
Mockito.when(fs.getStatus(new AlluxioURI("/foo/foobar_del"))).thenReturn(status1);
DeleteFileEntry deleteFileEntry = DeleteFileEntry.newBuilder().setId(100663295).setOpTimeMs(1515737580798L).setAlluxioOnly(true).setRecursive(false).build();
JournalEntry deleteFileJEntry = JournalEntry.newBuilder().setDeleteFile(deleteFileEntry).build();
entryApplier.apply(deleteFileJEntry);
List<FileDiff> fileDiffs = metaStore.getFileDiffsByFileName("/foo/foobar_del");
Assert.assertTrue(fileDiffs.size() > 0);
for (FileDiff fileDiff : fileDiffs) {
if (fileDiff.getDiffType().equals(FileDiffType.DELETE)) {
Assert.assertEquals("/foo/foobar_del", fileDiff.getSrc());
}
}
}
use of org.smartdata.model.FileInfo in project SSM by Intel-bigdata.
the class TestAlluxioNamespaceFetcher method testNamespaceFetcher.
@Test
public void testNamespaceFetcher() throws Exception {
// create namespace:
// /dir1
// /dir2
// -dir21
// -dir22
// -file221
// -file222
// -file21
// /dir3
// -file31
fs.createDirectory(new AlluxioURI("/dir1"));
fs.createDirectory(new AlluxioURI("/dir2"));
fs.createDirectory(new AlluxioURI("/dir3"));
fs.createDirectory(new AlluxioURI("/dir2/dir21"));
fs.createDirectory(new AlluxioURI("/dir2/dir22"));
createFile("/dir3/file31");
createFile("/dir2/dir22/file221");
createFile("/dir2/dir22/file222");
createFile("/dir2/file21");
AlluxioNamespaceFetcher fetcher = new AlluxioNamespaceFetcher(fs, metaStore, 100, Executors.newScheduledThreadPool(4));
fetcher.startFetch();
// wait complete
while (!fetcher.fetchFinished()) {
Thread.sleep(1000);
}
Thread.sleep(2000);
assertEquals(10, metaStore.getFile().size());
FileInfo dir1 = metaStore.getFile("/dir2/dir22");
assertTrue(dir1 != null);
assertTrue(dir1.isdir());
FileInfo file1 = metaStore.getFile("/dir2/dir22/file221");
assertTrue(file1 != null);
assertFalse(file1.isdir());
assertEquals(1, file1.getBlockReplication());
}
Aggregations