Repository: accumulo Updated Branches: refs/heads/ACCUMULO-4463 5af81142b -> 61dd0368d
ACCUMULO-4463: Updated property description, removed static field from BlockCacheManager, other review items... Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/61dd0368 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/61dd0368 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/61dd0368 Branch: refs/heads/ACCUMULO-4463 Commit: 61dd0368d562abc1c72dc61fef99296ecfc0490d Parents: 5af8114 Author: Dave Marion <[email protected]> Authored: Fri May 12 16:06:00 2017 -0400 Committer: Dave Marion <[email protected]> Committed: Fri May 12 16:06:00 2017 -0400 ---------------------------------------------------------------------- .../core/client/rfile/RFileScanner.java | 4 ++- .../org/apache/accumulo/core/conf/Property.java | 5 ++-- .../file/blockfile/cache/BlockCacheManager.java | 30 ++++++-------------- .../cache/lru/LruBlockCacheManager.java | 9 +++--- 4 files changed, 20 insertions(+), 28 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/61dd0368/core/src/main/java/org/apache/accumulo/core/client/rfile/RFileScanner.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/rfile/RFileScanner.java b/core/src/main/java/org/apache/accumulo/core/client/rfile/RFileScanner.java index 42eba78..205e3ea 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/rfile/RFileScanner.java +++ b/core/src/main/java/org/apache/accumulo/core/client/rfile/RFileScanner.java @@ -147,7 +147,9 @@ class RFileScanner extends ScannerOptions implements Scanner { } else { cc = new ConfigurationCopy(new DefaultConfiguration()); } - cc.set(Property.TSERV_DEFAULT_BLOCKSIZE, Long.toString(CACHE_BLOCK_SIZE)); + if (null == cc.get(Property.TSERV_DEFAULT_BLOCKSIZE)) { + cc.set(Property.TSERV_DEFAULT_BLOCKSIZE, Long.toString(CACHE_BLOCK_SIZE)); + } try { blockCacheManager = BlockCacheManager.getClientInstance(cc); if (opts.indexCacheSize > 0) { http://git-wip-us.apache.org/repos/asf/accumulo/blob/61dd0368/core/src/main/java/org/apache/accumulo/core/conf/Property.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/conf/Property.java b/core/src/main/java/org/apache/accumulo/core/conf/Property.java index c74ed8c..3547fac 100644 --- a/core/src/main/java/org/apache/accumulo/core/conf/Property.java +++ b/core/src/main/java/org/apache/accumulo/core/conf/Property.java @@ -245,8 +245,9 @@ public enum Property { TSERV_PREFIX("tserver.", null, PropertyType.PREFIX, "Properties in this category affect the behavior of the tablet servers"), TSERV_CLIENT_TIMEOUT("tserver.client.timeout", "3s", PropertyType.TIMEDURATION, "Time to wait for clients to continue scans before closing a session."), TSERV_DEFAULT_BLOCKSIZE("tserver.default.blocksize", "1M", PropertyType.BYTES, "Specifies a default blocksize for the tserver caches"), - TSERV_CACHE_FACTORY_IMPL("tserver.cache.factory.class", "org.apache.accumulo.core.file.blockfile.cache.lru.LruBlockCacheFactory", PropertyType.STRING, - "Specifies the class name of the block cache factory implementation."), + TSERV_CACHE_FACTORY_IMPL("tserver.cache.factory.class", "org.apache.accumulo.core.file.blockfile.cache.lru.LruBlockCacheManager", PropertyType.STRING, + "Specifies the class name of the block cache factory implementation. Alternative implementation is " + + "org.apache.accumulo.core.file.blockfile.cache.tinylfu.TinyLfuBlockCacheManager"), TSERV_DATACACHE_SIZE("tserver.cache.data.size", "10%", PropertyType.MEMORY, "Specifies the size of the cache for file data blocks."), TSERV_INDEXCACHE_SIZE("tserver.cache.index.size", "25%", PropertyType.MEMORY, "Specifies the size of the cache for file indices."), TSERV_SUMMARYCACHE_SIZE("tserver.cache.summary.size", "10%", PropertyType.MEMORY, "Specifies the size of the cache for summary data on each tablet server."), http://git-wip-us.apache.org/repos/asf/accumulo/blob/61dd0368/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/BlockCacheManager.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/BlockCacheManager.java b/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/BlockCacheManager.java index b1da718..025e834 100644 --- a/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/BlockCacheManager.java +++ b/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/BlockCacheManager.java @@ -31,9 +31,8 @@ public abstract class BlockCacheManager { public static final String CACHE_PROPERTY_BASE = Property.GENERAL_ARBITRARY_PROP_PREFIX + "cache.block."; private static final Logger LOG = LoggerFactory.getLogger(BlockCacheManager.class); - private static BlockCacheManager manager = null; - protected final Map<CacheType,BlockCache> caches = new HashMap<>(); + private final Map<CacheType,BlockCache> caches = new HashMap<>(); /** * Initialize the caches for each CacheType based on the configuration @@ -53,11 +52,6 @@ public abstract class BlockCacheManager { */ public void stop() { this.caches.clear(); - close(); - } - - private static synchronized void close() { - manager = null; } /** @@ -90,13 +84,10 @@ public abstract class BlockCacheManager { * error loading block cache manager implementation class */ public static synchronized BlockCacheManager getInstance(AccumuloConfiguration conf) throws Exception { - if (null == manager) { - String impl = conf.get(Property.TSERV_CACHE_FACTORY_IMPL); - Class<? extends BlockCacheManager> clazz = AccumuloVFSClassLoader.loadClass(impl, BlockCacheManager.class); - manager = (BlockCacheManager) clazz.newInstance(); - LOG.info("Created new block cache manager of type: {}", clazz.getSimpleName()); - } - return manager; + String impl = conf.get(Property.TSERV_CACHE_FACTORY_IMPL); + Class<? extends BlockCacheManager> clazz = AccumuloVFSClassLoader.loadClass(impl, BlockCacheManager.class); + LOG.info("Created new block cache manager of type: {}", clazz.getSimpleName()); + return (BlockCacheManager) clazz.newInstance(); } /** @@ -109,13 +100,10 @@ public abstract class BlockCacheManager { * error loading block cache manager implementation class */ public static synchronized BlockCacheManager getClientInstance(AccumuloConfiguration conf) throws Exception { - if (null == manager) { - String impl = conf.get(Property.TSERV_CACHE_FACTORY_IMPL); - Class<? extends BlockCacheManager> clazz = Class.forName(impl).asSubclass(BlockCacheManager.class); - manager = (BlockCacheManager) clazz.newInstance(); - LOG.info("Created new block cache factory of type: {}", clazz.getSimpleName()); - } - return manager; + String impl = conf.get(Property.TSERV_CACHE_FACTORY_IMPL); + Class<? extends BlockCacheManager> clazz = Class.forName(impl).asSubclass(BlockCacheManager.class); + LOG.info("Created new block cache factory of type: {}", clazz.getSimpleName()); + return (BlockCacheManager) clazz.newInstance(); } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/61dd0368/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/lru/LruBlockCacheManager.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/lru/LruBlockCacheManager.java b/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/lru/LruBlockCacheManager.java index 82d9142..8a1e430 100644 --- a/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/lru/LruBlockCacheManager.java +++ b/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/lru/LruBlockCacheManager.java @@ -17,8 +17,6 @@ */ package org.apache.accumulo.core.file.blockfile.cache.lru; -import java.util.Map.Entry; - import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.file.blockfile.cache.BlockCache; import org.apache.accumulo.core.file.blockfile.cache.BlockCacheManager; @@ -39,8 +37,11 @@ public class LruBlockCacheManager extends BlockCacheManager { @Override public void stop() { - for (Entry<CacheType,BlockCache> e : this.caches.entrySet()) { - ((LruBlockCache) e.getValue()).shutdown(); + for (CacheType type : CacheType.values()) { + LruBlockCache cache = ((LruBlockCache) this.getBlockCache(type)); + if (null != cache) { + cache.shutdown(); + } } super.stop(); }
