Search in sources :

Example 6 with AlluxioEntryApplier

use of org.smartdata.alluxio.metric.fetcher.AlluxioEntryApplier 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"));
        }
    }
}
Also used : AlluxioEntryApplier(org.smartdata.alluxio.metric.fetcher.AlluxioEntryApplier) URIStatus(alluxio.client.file.URIStatus) JournalEntry(alluxio.proto.journal.Journal.JournalEntry) FileInfo(org.smartdata.model.FileInfo) BackUpInfo(org.smartdata.model.BackUpInfo) FileSystem(alluxio.client.file.FileSystem) FileDiff(org.smartdata.model.FileDiff) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Aggregations

AlluxioURI (alluxio.AlluxioURI)6 FileSystem (alluxio.client.file.FileSystem)6 URIStatus (alluxio.client.file.URIStatus)6 JournalEntry (alluxio.proto.journal.Journal.JournalEntry)6 Test (org.junit.Test)6 AlluxioEntryApplier (org.smartdata.alluxio.metric.fetcher.AlluxioEntryApplier)6 FileInfo (org.smartdata.model.FileInfo)6 BackUpInfo (org.smartdata.model.BackUpInfo)5 FileDiff (org.smartdata.model.FileDiff)5