Search in sources :

Example 1 with DefaultConfiguration

use of org.apache.accumulo.core.conf.DefaultConfiguration in project accumulo by apache.

the class ServerConfigurationFactoryTest method testGetDefaultConfiguration.

@Test
public void testGetDefaultConfiguration() {
    ready();
    DefaultConfiguration c = scf.getDefaultConfiguration();
    assertNotNull(c);
}
Also used : DefaultConfiguration(org.apache.accumulo.core.conf.DefaultConfiguration) Test(org.junit.Test)

Example 2 with DefaultConfiguration

use of org.apache.accumulo.core.conf.DefaultConfiguration in project accumulo by apache.

the class BlockCacheFactoryTest method testStartWithDefault.

@Test
public void testStartWithDefault() throws Exception {
    DefaultConfiguration dc = DefaultConfiguration.getInstance();
    BlockCacheManager manager = BlockCacheManagerFactory.getInstance(dc);
    manager.start(new BlockCacheConfiguration(dc));
    Assert.assertNotNull(manager.getBlockCache(CacheType.INDEX));
}
Also used : DefaultConfiguration(org.apache.accumulo.core.conf.DefaultConfiguration) LruBlockCacheManager(org.apache.accumulo.core.file.blockfile.cache.lru.LruBlockCacheManager) TinyLfuBlockCacheManager(org.apache.accumulo.core.file.blockfile.cache.tinylfu.TinyLfuBlockCacheManager) BlockCacheConfiguration(org.apache.accumulo.core.file.blockfile.cache.impl.BlockCacheConfiguration) Test(org.junit.Test)

Example 3 with DefaultConfiguration

use of org.apache.accumulo.core.conf.DefaultConfiguration in project accumulo by apache.

the class BlockCacheFactoryTest method testCreateTinyLfuBlockCacheFactory.

@Test
public void testCreateTinyLfuBlockCacheFactory() throws Exception {
    DefaultConfiguration dc = DefaultConfiguration.getInstance();
    ConfigurationCopy cc = new ConfigurationCopy(dc);
    cc.set(Property.TSERV_CACHE_MANAGER_IMPL, TinyLfuBlockCacheManager.class.getName());
    BlockCacheManagerFactory.getInstance(cc);
}
Also used : ConfigurationCopy(org.apache.accumulo.core.conf.ConfigurationCopy) TinyLfuBlockCacheManager(org.apache.accumulo.core.file.blockfile.cache.tinylfu.TinyLfuBlockCacheManager) DefaultConfiguration(org.apache.accumulo.core.conf.DefaultConfiguration) Test(org.junit.Test)

Example 4 with DefaultConfiguration

use of org.apache.accumulo.core.conf.DefaultConfiguration in project accumulo by apache.

the class TestLruBlockCache method testCacheSimple.

public void testCacheSimple() throws Exception {
    long maxSize = 1000000;
    long blockSize = calculateBlockSizeDefault(maxSize, 101);
    DefaultConfiguration dc = DefaultConfiguration.getInstance();
    ConfigurationCopy cc = new ConfigurationCopy(dc);
    cc.set(Property.TSERV_CACHE_MANAGER_IMPL, LruBlockCacheManager.class.getName());
    BlockCacheManager manager = BlockCacheManagerFactory.getInstance(cc);
    cc.set(Property.TSERV_DEFAULT_BLOCKSIZE, Long.toString(blockSize));
    cc.set(Property.TSERV_INDEXCACHE_SIZE, Long.toString(maxSize));
    manager.start(new BlockCacheConfiguration(cc));
    LruBlockCache cache = (LruBlockCache) manager.getBlockCache(CacheType.INDEX);
    Block[] blocks = generateRandomBlocks(100, blockSize);
    long expectedCacheSize = cache.heapSize();
    // Confirm empty
    for (Block block : blocks) {
        assertTrue(cache.getBlock(block.blockName) == null);
    }
    // Add blocks
    for (Block block : blocks) {
        cache.cacheBlock(block.blockName, block.buf);
        expectedCacheSize += block.heapSize();
    }
    // Verify correctly calculated cache heap size
    assertEquals(expectedCacheSize, cache.heapSize());
    // Check if all blocks are properly cached and retrieved
    for (Block block : blocks) {
        CacheEntry ce = cache.getBlock(block.blockName);
        assertTrue(ce != null);
        assertEquals(ce.getBuffer().length, block.buf.length);
    }
    // Verify correctly calculated cache heap size
    assertEquals(expectedCacheSize, cache.heapSize());
    // Check if all blocks are properly cached and retrieved
    for (Block block : blocks) {
        CacheEntry ce = cache.getBlock(block.blockName);
        assertTrue(ce != null);
        assertEquals(ce.getBuffer().length, block.buf.length);
    }
    // Expect no evictions
    assertEquals(0, cache.getEvictionCount());
    // Thread t = new LruBlockCache.StatisticsThread(cache);
    // t.start();
    // t.join();
    manager.stop();
}
Also used : LruBlockCache(org.apache.accumulo.core.file.blockfile.cache.lru.LruBlockCache) ConfigurationCopy(org.apache.accumulo.core.conf.ConfigurationCopy) LruBlockCacheManager(org.apache.accumulo.core.file.blockfile.cache.lru.LruBlockCacheManager) CachedBlock(org.apache.accumulo.core.file.blockfile.cache.lru.CachedBlock) DefaultConfiguration(org.apache.accumulo.core.conf.DefaultConfiguration) LruBlockCacheManager(org.apache.accumulo.core.file.blockfile.cache.lru.LruBlockCacheManager) BlockCacheConfiguration(org.apache.accumulo.core.file.blockfile.cache.impl.BlockCacheConfiguration) LruBlockCacheConfiguration(org.apache.accumulo.core.file.blockfile.cache.lru.LruBlockCacheConfiguration)

Example 5 with DefaultConfiguration

use of org.apache.accumulo.core.conf.DefaultConfiguration in project accumulo by apache.

the class TestLruBlockCache method testCacheEvictionSimple.

public void testCacheEvictionSimple() throws Exception {
    long maxSize = 100000;
    long blockSize = calculateBlockSizeDefault(maxSize, 10);
    DefaultConfiguration dc = DefaultConfiguration.getInstance();
    ConfigurationCopy cc = new ConfigurationCopy(dc);
    cc.set(Property.TSERV_CACHE_MANAGER_IMPL, LruBlockCacheManager.class.getName());
    BlockCacheManager manager = BlockCacheManagerFactory.getInstance(cc);
    cc.set(Property.TSERV_DEFAULT_BLOCKSIZE, Long.toString(blockSize));
    cc.set(Property.TSERV_INDEXCACHE_SIZE, Long.toString(maxSize));
    LruBlockCacheConfiguration.builder(CacheType.INDEX).useEvictionThread(false).buildMap().forEach(cc::set);
    manager.start(new BlockCacheConfiguration(cc));
    LruBlockCache cache = (LruBlockCache) manager.getBlockCache(CacheType.INDEX);
    Block[] blocks = generateFixedBlocks(10, blockSize, "block");
    long expectedCacheSize = cache.heapSize();
    // Add all the blocks
    for (Block block : blocks) {
        cache.cacheBlock(block.blockName, block.buf);
        expectedCacheSize += block.heapSize();
    }
    // A single eviction run should have occurred
    assertEquals(1, cache.getEvictionCount());
    // Our expected size overruns acceptable limit
    assertTrue(expectedCacheSize > (maxSize * LruBlockCacheConfiguration.DEFAULT_ACCEPTABLE_FACTOR));
    // But the cache did not grow beyond max
    assertTrue(cache.heapSize() < maxSize);
    // And is still below the acceptable limit
    assertTrue(cache.heapSize() < (maxSize * LruBlockCacheConfiguration.DEFAULT_ACCEPTABLE_FACTOR));
    // All blocks except block 0 and 1 should be in the cache
    assertTrue(cache.getBlock(blocks[0].blockName) == null);
    assertTrue(cache.getBlock(blocks[1].blockName) == null);
    for (int i = 2; i < blocks.length; i++) {
        assertTrue(Arrays.equals(cache.getBlock(blocks[i].blockName).getBuffer(), blocks[i].buf));
    }
    manager.stop();
}
Also used : LruBlockCache(org.apache.accumulo.core.file.blockfile.cache.lru.LruBlockCache) ConfigurationCopy(org.apache.accumulo.core.conf.ConfigurationCopy) LruBlockCacheManager(org.apache.accumulo.core.file.blockfile.cache.lru.LruBlockCacheManager) CachedBlock(org.apache.accumulo.core.file.blockfile.cache.lru.CachedBlock) DefaultConfiguration(org.apache.accumulo.core.conf.DefaultConfiguration) LruBlockCacheManager(org.apache.accumulo.core.file.blockfile.cache.lru.LruBlockCacheManager) BlockCacheConfiguration(org.apache.accumulo.core.file.blockfile.cache.impl.BlockCacheConfiguration) LruBlockCacheConfiguration(org.apache.accumulo.core.file.blockfile.cache.lru.LruBlockCacheConfiguration)

Aggregations

DefaultConfiguration (org.apache.accumulo.core.conf.DefaultConfiguration)16 ConfigurationCopy (org.apache.accumulo.core.conf.ConfigurationCopy)9 LruBlockCacheManager (org.apache.accumulo.core.file.blockfile.cache.lru.LruBlockCacheManager)8 BlockCacheConfiguration (org.apache.accumulo.core.file.blockfile.cache.impl.BlockCacheConfiguration)7 CachedBlock (org.apache.accumulo.core.file.blockfile.cache.lru.CachedBlock)6 LruBlockCache (org.apache.accumulo.core.file.blockfile.cache.lru.LruBlockCache)6 LruBlockCacheConfiguration (org.apache.accumulo.core.file.blockfile.cache.lru.LruBlockCacheConfiguration)6 Test (org.junit.Test)5 File (java.io.File)3 FileFilter (java.io.FileFilter)2 Connector (org.apache.accumulo.core.client.Connector)2 SamplerConfiguration (org.apache.accumulo.core.client.sample.SamplerConfiguration)2 Property (org.apache.accumulo.core.conf.Property)2 FileSKVIterator (org.apache.accumulo.core.file.FileSKVIterator)2 TinyLfuBlockCacheManager (org.apache.accumulo.core.file.blockfile.cache.tinylfu.TinyLfuBlockCacheManager)2 SamplerConfigurationImpl (org.apache.accumulo.core.sample.impl.SamplerConfigurationImpl)2 CachedConfiguration (org.apache.accumulo.core.util.CachedConfiguration)2 Configuration (org.apache.hadoop.conf.Configuration)2 OutputStreamWriter (java.io.OutputStreamWriter)1 Collection (java.util.Collection)1