Search in sources :

Example 1 with AlluxioNamespaceFetcher

use of org.smartdata.alluxio.metric.fetcher.AlluxioNamespaceFetcher 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());
}
Also used : FileInfo(org.smartdata.model.FileInfo) AlluxioNamespaceFetcher(org.smartdata.alluxio.metric.fetcher.AlluxioNamespaceFetcher) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Aggregations

AlluxioURI (alluxio.AlluxioURI)1 Test (org.junit.Test)1 AlluxioNamespaceFetcher (org.smartdata.alluxio.metric.fetcher.AlluxioNamespaceFetcher)1 FileInfo (org.smartdata.model.FileInfo)1