Search in sources :

Example 1 with PageInfo

use of alluxio.client.file.cache.PageInfo in project alluxio by Alluxio.

the class PageStoreTest method getPages.

@Test
public void getPages() throws Exception {
    int len = 32;
    int count = 16;
    byte[] data = BufferUtils.getIncreasingByteArray(len);
    Set<PageInfo> pages = new HashSet<>(count);
    for (int i = 0; i < count; i++) {
        PageId id = new PageId("0", i);
        mPageStore.put(id, data);
        pages.add(new PageInfo(id, data.length));
    }
    Set<PageInfo> restored = mPageStore.getPages().collect(Collectors.toSet());
    assertEquals(pages, restored);
}
Also used : PageId(alluxio.client.file.cache.PageId) PageInfo(alluxio.client.file.cache.PageInfo) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with PageInfo

use of alluxio.client.file.cache.PageInfo in project alluxio by Alluxio.

the class PageStoreTest method getPagesUUID.

@Test
public void getPagesUUID() throws Exception {
    int len = 32;
    int count = 16;
    byte[] data = BufferUtils.getIncreasingByteArray(len);
    Set<PageInfo> pages = new HashSet<>(count);
    for (int i = 0; i < count; i++) {
        PageId id = new PageId(UUID.randomUUID().toString(), i);
        mPageStore.put(id, data);
        pages.add(new PageInfo(id, data.length));
    }
    Set<PageInfo> restored = mPageStore.getPages().collect(Collectors.toSet());
    assertEquals(pages, restored);
}
Also used : PageId(alluxio.client.file.cache.PageId) PageInfo(alluxio.client.file.cache.PageInfo) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with PageInfo

use of alluxio.client.file.cache.PageInfo in project alluxio by Alluxio.

the class LocalPageStore method getPageInfo.

/**
 * @param path path of a file
 * @return the corresponding page info for the file otherwise null
 */
@Nullable
private PageInfo getPageInfo(Path path) {
    PageId pageId = getPageId(path);
    long pageSize;
    if (pageId == null) {
        LOG.error("Unrecognized page file" + path);
        return null;
    }
    try {
        pageSize = Files.size(path);
    } catch (IOException e) {
        LOG.error("Failed to get file size for " + path, e);
        return null;
    }
    return new PageInfo(pageId, pageSize);
}
Also used : PageId(alluxio.client.file.cache.PageId) PageInfo(alluxio.client.file.cache.PageInfo) IOException(java.io.IOException) Nullable(javax.annotation.Nullable)

Aggregations

PageId (alluxio.client.file.cache.PageId)3 PageInfo (alluxio.client.file.cache.PageInfo)3 HashSet (java.util.HashSet)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 Nullable (javax.annotation.Nullable)1