Search in sources :

Example 11 with PageId

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

the class MemoryPageStoreTest method helloWorldTest.

private void helloWorldTest(PageStore store) throws Exception {
    String msg = "Hello, World!";
    PageId id = new PageId("0", 0);
    store.put(id, msg.getBytes());
    byte[] buf = new byte[1024];
    assertEquals(msg.getBytes().length, store.get(id, buf));
    assertArrayEquals(msg.getBytes(), Arrays.copyOfRange(buf, 0, msg.getBytes().length));
}
Also used : PageId(alluxio.client.file.cache.PageId)

Example 12 with PageId

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

the class LocalPageStoreTest method testMultiFileBucket.

@Test
public void testMultiFileBucket() throws Exception {
    int numBuckets = 10;
    mOptions.setFileBuckets(numBuckets);
    LocalPageStore pageStore = new LocalPageStore(mOptions);
    long numFiles = numBuckets * 10;
    for (int i = 0; i < numFiles; i++) {
        PageId id = new PageId(Integer.toString(i), 0);
        pageStore.put(id, "test".getBytes());
    }
    long actualCount = 0;
    for (Path root : mOptions.getRootDirs()) {
        actualCount += Files.list(Paths.get(root.toString(), Long.toString(mOptions.getPageSize()))).count();
    }
    assertEquals(10, actualCount);
}
Also used : PageId(alluxio.client.file.cache.PageId) Path(java.nio.file.Path) Test(org.junit.Test)

Example 13 with PageId

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

the class LocalPageStoreTest method helloWorldTest.

private void helloWorldTest(PageStore store) throws Exception {
    String msg = "Hello, World!";
    PageId id = new PageId("0", 0);
    store.put(id, msg.getBytes());
    byte[] buf = new byte[1024];
    assertEquals(msg.getBytes().length, store.get(id, buf));
    assertArrayEquals(msg.getBytes(), Arrays.copyOfRange(buf, 0, msg.getBytes().length));
}
Also used : PageId(alluxio.client.file.cache.PageId)

Example 14 with PageId

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

the class PageStoreTest method getSmallLen.

@Test
public void getSmallLen() throws Exception {
    int len = 32;
    PageId id = new PageId("0", 0);
    mPageStore.put(id, BufferUtils.getIncreasingByteArray(len));
    byte[] buf = new byte[1024];
    for (int b = 1; b < len; b++) {
        int bytesRead = mPageStore.get(id, 0, b, buf, 0);
        assertEquals(b, bytesRead);
        assertArrayEquals(BufferUtils.getIncreasingByteArray(b), Arrays.copyOfRange(buf, 0, bytesRead));
    }
}
Also used : PageId(alluxio.client.file.cache.PageId) Test(org.junit.Test)

Example 15 with PageId

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

the class PageStoreTest method getOffset.

@Test
public void getOffset() throws Exception {
    int len = 32;
    PageId id = new PageId("0", 0);
    mPageStore.put(id, BufferUtils.getIncreasingByteArray(len));
    byte[] buf = new byte[len];
    for (int offset = 1; offset < len; offset++) {
        int bytesRead = mPageStore.get(id, offset, len, buf, 0);
        assertEquals(len - offset, bytesRead);
        assertArrayEquals(BufferUtils.getIncreasingByteArray(offset, len - offset), Arrays.copyOfRange(buf, 0, bytesRead));
    }
}
Also used : PageId(alluxio.client.file.cache.PageId) Test(org.junit.Test)

Aggregations

PageId (alluxio.client.file.cache.PageId)22 Test (org.junit.Test)11 Nullable (javax.annotation.Nullable)5 PageNotFoundException (alluxio.exception.PageNotFoundException)4 PageInfo (alluxio.client.file.cache.PageInfo)3 Path (java.nio.file.Path)3 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 ResourceExhaustedException (alluxio.exception.status.ResourceExhaustedException)1 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 Matcher (java.util.regex.Matcher)1