Search in sources :

Example 1 with LocalPageStore

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));
}
Also used : LocalPageStore(alluxio.client.file.cache.store.LocalPageStore) ResourceExhaustedException(alluxio.exception.status.ResourceExhaustedException) Test(org.junit.Test)

Example 2 with LocalPageStore

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;
}
Also used : LocalPageStore(alluxio.client.file.cache.store.LocalPageStore) MemoryPageStore(alluxio.client.file.cache.store.MemoryPageStore) LocalPageStore(alluxio.client.file.cache.store.LocalPageStore) RocksPageStore(alluxio.client.file.cache.store.RocksPageStore) MemoryPageStore(alluxio.client.file.cache.store.MemoryPageStore)

Aggregations

LocalPageStore (alluxio.client.file.cache.store.LocalPageStore)2 MemoryPageStore (alluxio.client.file.cache.store.MemoryPageStore)1 RocksPageStore (alluxio.client.file.cache.store.RocksPageStore)1 ResourceExhaustedException (alluxio.exception.status.ResourceExhaustedException)1 Test (org.junit.Test)1