Package org.apache.accumulo.core.file.blockfile.cache

Examples of org.apache.accumulo.core.file.blockfile.cache.LruBlockCache


  public void testResizeBlockCache() throws Exception {
   
    long maxSize = 300000;
    long blockSize = calculateBlockSize(maxSize, 31);
   
    LruBlockCache cache = new LruBlockCache(maxSize, blockSize, false, (int) Math.ceil(1.2 * maxSize / blockSize), LruBlockCache.DEFAULT_LOAD_FACTOR,
        LruBlockCache.DEFAULT_CONCURRENCY_LEVEL, 0.98f, // min
        0.99f, // acceptable
        0.33f, // single
        0.33f, // multi
        0.34f);// memory
   
    Block[] singleBlocks = generateFixedBlocks(10, blockSize, "single");
    Block[] multiBlocks = generateFixedBlocks(10, blockSize, "multi");
    Block[] memoryBlocks = generateFixedBlocks(10, blockSize, "memory");
   
    // Add all blocks from all priorities
    for (int i = 0; i < 10; i++) {
     
      // Just add single blocks
      cache.cacheBlock(singleBlocks[i].blockName, singleBlocks[i].buf);
     
      // Add and get multi blocks
      cache.cacheBlock(multiBlocks[i].blockName, multiBlocks[i].buf);
      cache.getBlock(multiBlocks[i].blockName);
     
      // Add memory blocks as such
      cache.cacheBlock(memoryBlocks[i].blockName, memoryBlocks[i].buf, true);
    }
   
    // Do not expect any evictions yet
    assertEquals(0, cache.getEvictionCount());
   
    // Resize to half capacity plus an extra block (otherwise we evict an extra)
    cache.setMaxSize((long) (maxSize * 0.5f));
   
    // Should have run a single eviction
    assertEquals(1, cache.getEvictionCount());
   
    // And we expect 1/2 of the blocks to be evicted
    assertEquals(15, cache.getEvictedCount());
   
    // And the oldest 5 blocks from each category should be gone
    for (int i = 0; i < 5; i++) {
      assertEquals(null, cache.getBlock(singleBlocks[i].blockName));
      assertEquals(null, cache.getBlock(multiBlocks[i].blockName));
      assertEquals(null, cache.getBlock(memoryBlocks[i].blockName));
    }
   
    // And the newest 5 blocks should still be accessible
    for (int i = 5; i < 10; i++) {
      assertEquals(singleBlocks[i].buf, cache.getBlock(singleBlocks[i].blockName));
      assertEquals(multiBlocks[i].buf, cache.getBlock(multiBlocks[i].blockName));
      assertEquals(memoryBlocks[i].buf, cache.getBlock(memoryBlocks[i].blockName));
    }
  }
View Full Code Here


   
    long blockSize = acuConf.getMemoryInBytes(Property.TSERV_DEFAULT_BLOCKSIZE);
    long dCacheSize = acuConf.getMemoryInBytes(Property.TSERV_DATACACHE_SIZE);
    long iCacheSize = acuConf.getMemoryInBytes(Property.TSERV_INDEXCACHE_SIZE);
   
    _iCache = new LruBlockCache(iCacheSize, blockSize);
    _dCache = new LruBlockCache(dCacheSize, blockSize);
   
    Runtime runtime = Runtime.getRuntime();
    if (!usingNativeMap && maxMemory > runtime.maxMemory()) {
      throw new IllegalArgumentException(String.format("Maximum tablet server map memory %,d is too large for this JVM configuration %,d", maxMemory,
          runtime.maxMemory()));
View Full Code Here

TOP

Related Classes of org.apache.accumulo.core.file.blockfile.cache.LruBlockCache

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.