Search in sources :

Example 1 with LruBlockCacheConfiguration

use of org.apache.accumulo.core.file.blockfile.cache.lru.LruBlockCacheConfiguration in project accumulo by apache.

the class TestLruBlockCache method testConfiguration.

public void testConfiguration() {
    ConfigurationCopy cc = new ConfigurationCopy();
    cc.set(Property.TSERV_CACHE_MANAGER_IMPL, LruBlockCacheManager.class.getName());
    cc.set(Property.TSERV_DEFAULT_BLOCKSIZE, Long.toString(1019));
    cc.set(Property.TSERV_INDEXCACHE_SIZE, Long.toString(1000023));
    cc.set(Property.TSERV_DATACACHE_SIZE, Long.toString(1000027));
    cc.set(Property.TSERV_SUMMARYCACHE_SIZE, Long.toString(1000029));
    LruBlockCacheConfiguration.builder(CacheType.INDEX).useEvictionThread(false).minFactor(0.93f).acceptableFactor(0.97f).singleFactor(0.20f).multiFactor(0.30f).memoryFactor(0.50f).mapConcurrencyLevel(5).buildMap().forEach(cc::set);
    String defaultPrefix = BlockCacheManager.CACHE_PROPERTY_BASE + LruBlockCacheConfiguration.PROPERTY_PREFIX + ".default.";
    // this should be overridden by cache type specific setting
    cc.set(defaultPrefix + LruBlockCacheConfiguration.MEMORY_FACTOR_PROPERTY, "0.6");
    // this is not set for the cache type, so should fall back to default
    cc.set(defaultPrefix + LruBlockCacheConfiguration.MAP_LOAD_PROPERTY, "0.53");
    BlockCacheConfiguration bcc = new BlockCacheConfiguration(cc);
    LruBlockCacheConfiguration lbcc = new LruBlockCacheConfiguration(bcc, CacheType.INDEX);
    assertEquals(false, lbcc.isUseEvictionThread());
    assertEquals(0.93f, lbcc.getMinFactor());
    assertEquals(0.97f, lbcc.getAcceptableFactor());
    assertEquals(0.20f, lbcc.getSingleFactor());
    assertEquals(0.30f, lbcc.getMultiFactor());
    assertEquals(0.50f, lbcc.getMemoryFactor());
    assertEquals(0.53f, lbcc.getMapLoadFactor());
    assertEquals(5, lbcc.getMapConcurrencyLevel());
    assertEquals(1019, lbcc.getBlockSize());
    assertEquals(1000023, lbcc.getMaxSize());
}
Also used : ConfigurationCopy(org.apache.accumulo.core.conf.ConfigurationCopy) LruBlockCacheManager(org.apache.accumulo.core.file.blockfile.cache.lru.LruBlockCacheManager) LruBlockCacheConfiguration(org.apache.accumulo.core.file.blockfile.cache.lru.LruBlockCacheConfiguration) BlockCacheConfiguration(org.apache.accumulo.core.file.blockfile.cache.impl.BlockCacheConfiguration) LruBlockCacheConfiguration(org.apache.accumulo.core.file.blockfile.cache.lru.LruBlockCacheConfiguration)

Aggregations

ConfigurationCopy (org.apache.accumulo.core.conf.ConfigurationCopy)1 BlockCacheConfiguration (org.apache.accumulo.core.file.blockfile.cache.impl.BlockCacheConfiguration)1 LruBlockCacheConfiguration (org.apache.accumulo.core.file.blockfile.cache.lru.LruBlockCacheConfiguration)1 LruBlockCacheManager (org.apache.accumulo.core.file.blockfile.cache.lru.LruBlockCacheManager)1