use of alluxio.client.file.cache.PageId in project alluxio by Alluxio.
the class LocalPageStoreTest method testSingleFileBucket.
@Test
public void testSingleFileBucket() throws Exception {
mOptions.setFileBuckets(1);
LocalPageStore pageStore = new LocalPageStore(mOptions);
long numFiles = 100;
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(mRootDirCount, actualCount);
}
use of alluxio.client.file.cache.PageId 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);
}
use of alluxio.client.file.cache.PageId in project alluxio by Alluxio.
the class PageStoreTest method helloWorldTest.
@Test
public void helloWorldTest() throws Exception {
String msg = "Hello, World!";
byte[] msgBytes = msg.getBytes();
PageId id = new PageId("0", 0);
mPageStore.put(id, msgBytes);
byte[] buf = new byte[1024];
assertEquals(msgBytes.length, mPageStore.get(id, buf));
assertArrayEquals(msgBytes, Arrays.copyOfRange(buf, 0, msgBytes.length));
mPageStore.delete(id);
try {
mPageStore.get(id, buf);
fail();
} catch (PageNotFoundException e) {
// Test completed successfully;
}
}
use of alluxio.client.file.cache.PageId 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);
}
use of alluxio.client.file.cache.PageId in project alluxio by Alluxio.
the class PageStoreTest method getOffsetOverflow.
@Test
public void getOffsetOverflow() throws Exception {
int len = 32;
int offset = 36;
PageId id = new PageId("0", 0);
mPageStore.put(id, BufferUtils.getIncreasingByteArray(len));
byte[] buf = new byte[1024];
assertThrows(IllegalArgumentException.class, () -> mPageStore.get(id, offset, len, buf, 0));
}
Aggregations