use of alluxio.client.file.cache.store.LocalPageStore in project alluxio by Alluxio.
the class LocalCacheManagerTest method noSpaceLeftPageStorePut.
@Test
public void noSpaceLeftPageStorePut() throws Exception {
LocalPageStore pageStore = new LocalPageStore(PageStoreOptions.create(mConf).toOptions()) {
private long mFreeBytes = PAGE_SIZE_BYTES;
@Override
public void delete(PageId pageId) throws IOException, PageNotFoundException {
mFreeBytes += PAGE_SIZE_BYTES;
super.delete(pageId);
}
@Override
public void put(PageId pageId, byte[] page) throws IOException {
if (mFreeBytes < page.length) {
throw new ResourceExhaustedException("No space left on device");
}
mFreeBytes -= page.length;
super.put(pageId, page);
}
};
mCacheManager = createLocalCacheManager(mConf, mMetaStore, new TimeBoundPageStore(pageStore, mPageStoreOptions));
assertTrue(mCacheManager.put(PAGE_ID1, PAGE1));
// trigger evicting PAGE1
assertTrue(mCacheManager.put(PAGE_ID2, PAGE2));
assertEquals(0, mCacheManager.get(PAGE_ID1, PAGE1.length, mBuf, 0));
}
use of alluxio.client.file.cache.store.LocalPageStore in project alluxio by Alluxio.
the class PageStore method open.
/**
* Opens an existing {@link PageStore}.
*
* @param options the options to instantiate the page store
* @return a PageStore instance
* @throws IOException if I/O error happens
*/
static PageStore open(PageStoreOptions options) throws IOException {
LOG.info("Opening PageStore with option={}", options.toString());
final PageStore pageStore;
switch(options.getType()) {
case LOCAL:
pageStore = new LocalPageStore(options.toOptions());
break;
case ROCKS:
pageStore = RocksPageStore.open(options.toOptions());
break;
case MEM:
pageStore = new MemoryPageStore(options.toOptions());
break;
default:
throw new IllegalArgumentException("Incompatible PageStore " + options.getType() + " specified");
}
if (options.getTimeoutDuration() > 0) {
return new TimeBoundPageStore(pageStore, options);
}
return pageStore;
}
Aggregations