Skip to content

Commit

Permalink
Replaced tserv block cache mgr property with a more general one (apac…
Browse files Browse the repository at this point in the history
…he#5231)

The block cache manager is not only used in the tserver, it's
also used in the sserver and by a client that might be reading
from an RFile.

Closes apache#4663
  • Loading branch information
dlmarion authored Jan 8, 2025
1 parent 3d0bea9 commit 9e40a1e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 16 deletions.
15 changes: 12 additions & 3 deletions core/src/main/java/org/apache/accumulo/core/conf/Property.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,12 @@ public enum Property {
+ " user-implementations of pluggable Accumulo features, such as the balancer"
+ " or volume chooser.",
"2.0.0"),
GENERAL_CACHE_MANAGER_IMPL("general.block.cache.manager.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.",
"2.1.4"),
GENERAL_DELEGATION_TOKEN_LIFETIME("general.delegation.token.lifetime", "7d",
PropertyType.TIMEDURATION,
"The length of time that delegation tokens and secret keys are valid.", "1.7.0"),
Expand Down Expand Up @@ -532,7 +538,9 @@ public enum Property {
"Time to wait for clients to continue scans before closing a session.", "1.3.5"),
TSERV_DEFAULT_BLOCKSIZE("tserver.default.blocksize", "1M", PropertyType.BYTES,
"Specifies a default blocksize for the tserver caches.", "1.3.5"),
TSERV_CACHE_MANAGER_IMPL("tserver.cache.manager.class",
@Deprecated(since = "2.1.4")
@ReplacedBy(property = Property.GENERAL_CACHE_MANAGER_IMPL)
TSERV_CACHE_MANAGER_IMPL("general.cache.manager.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"
Expand Down Expand Up @@ -1873,8 +1881,9 @@ public static boolean isValidTablePropertyKey(String key) {
TSERV_MAX_MESSAGE_SIZE, GENERAL_MAX_MESSAGE_SIZE, RPC_MAX_MESSAGE_SIZE,

// block cache options
TSERV_CACHE_MANAGER_IMPL, TSERV_DATACACHE_SIZE, TSERV_INDEXCACHE_SIZE,
TSERV_SUMMARYCACHE_SIZE, SSERV_DATACACHE_SIZE, SSERV_INDEXCACHE_SIZE, SSERV_SUMMARYCACHE_SIZE,
GENERAL_CACHE_MANAGER_IMPL, TSERV_CACHE_MANAGER_IMPL, TSERV_DATACACHE_SIZE,
TSERV_INDEXCACHE_SIZE, TSERV_SUMMARYCACHE_SIZE, SSERV_DATACACHE_SIZE, SSERV_INDEXCACHE_SIZE,
SSERV_SUMMARYCACHE_SIZE,

// blocksize options
TSERV_DEFAULT_BLOCKSIZE, SSERV_DEFAULT_BLOCKSIZE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ public class BlockCacheManagerFactory {
*/
public static synchronized BlockCacheManager getInstance(AccumuloConfiguration conf)
throws Exception {
String impl = conf.get(Property.TSERV_CACHE_MANAGER_IMPL);
@SuppressWarnings("deprecation")
var cacheManagerProp =
conf.resolve(Property.GENERAL_CACHE_MANAGER_IMPL, Property.TSERV_CACHE_MANAGER_IMPL);
String impl = conf.get(cacheManagerProp);
Class<? extends BlockCacheManager> clazz =
ClassLoaderUtil.loadClass(impl, BlockCacheManager.class);
LOG.info("Created new block cache manager of type: {}", clazz.getSimpleName());
Expand All @@ -55,7 +58,10 @@ public static synchronized BlockCacheManager getInstance(AccumuloConfiguration c
*/
public static synchronized BlockCacheManager getClientInstance(AccumuloConfiguration conf)
throws Exception {
String impl = conf.get(Property.TSERV_CACHE_MANAGER_IMPL);
@SuppressWarnings("deprecation")
var cacheManagerProp =
conf.resolve(Property.GENERAL_CACHE_MANAGER_IMPL, Property.TSERV_CACHE_MANAGER_IMPL);
String impl = conf.get(cacheManagerProp);
Class<? extends BlockCacheManager> clazz =
Class.forName(impl).asSubclass(BlockCacheManager.class);
LOG.info("Created new block cache factory of type: {}", clazz.getSimpleName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ public class BlockCacheFactoryTest {
public void testCreateLruBlockCacheFactory() throws Exception {
DefaultConfiguration dc = DefaultConfiguration.getInstance();
ConfigurationCopy cc = new ConfigurationCopy(dc);
cc.set(Property.TSERV_CACHE_MANAGER_IMPL, LruBlockCacheManager.class.getName());
cc.set(Property.GENERAL_CACHE_MANAGER_IMPL, LruBlockCacheManager.class.getName());
BlockCacheManagerFactory.getInstance(cc);
}

@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());
cc.set(Property.GENERAL_CACHE_MANAGER_IMPL, TinyLfuBlockCacheManager.class.getName());
BlockCacheManagerFactory.getInstance(cc);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class TestLruBlockCache {
@Test
public void testConfiguration() {
ConfigurationCopy cc = new ConfigurationCopy();
cc.set(Property.TSERV_CACHE_MANAGER_IMPL, LruBlockCacheManager.class.getName());
cc.set(Property.GENERAL_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));
Expand Down Expand Up @@ -99,7 +99,7 @@ public void testBackgroundEvictionThread() throws Exception {

DefaultConfiguration dc = DefaultConfiguration.getInstance();
ConfigurationCopy cc = new ConfigurationCopy(dc);
cc.set(Property.TSERV_CACHE_MANAGER_IMPL, LruBlockCacheManager.class.getName());
cc.set(Property.GENERAL_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));
Expand Down Expand Up @@ -133,7 +133,7 @@ public void testCacheSimple() throws Exception {

DefaultConfiguration dc = DefaultConfiguration.getInstance();
ConfigurationCopy cc = new ConfigurationCopy(dc);
cc.set(Property.TSERV_CACHE_MANAGER_IMPL, LruBlockCacheManager.class.getName());
cc.set(Property.GENERAL_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));
Expand Down Expand Up @@ -191,7 +191,7 @@ public void testCacheEvictionSimple() throws Exception {

DefaultConfiguration dc = DefaultConfiguration.getInstance();
ConfigurationCopy cc = new ConfigurationCopy(dc);
cc.set(Property.TSERV_CACHE_MANAGER_IMPL, LruBlockCacheManager.class.getName());
cc.set(Property.GENERAL_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));
Expand Down Expand Up @@ -241,7 +241,7 @@ public void testCacheEvictionTwoPriorities() throws Exception {

DefaultConfiguration dc = DefaultConfiguration.getInstance();
ConfigurationCopy cc = new ConfigurationCopy(dc);
cc.set(Property.TSERV_CACHE_MANAGER_IMPL, LruBlockCacheManager.class.getName());
cc.set(Property.GENERAL_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));
Expand Down Expand Up @@ -309,7 +309,7 @@ public void testCacheEvictionThreePriorities() throws Exception {

DefaultConfiguration dc = DefaultConfiguration.getInstance();
ConfigurationCopy cc = new ConfigurationCopy(dc);
cc.set(Property.TSERV_CACHE_MANAGER_IMPL, LruBlockCacheManager.class.getName());
cc.set(Property.GENERAL_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));
Expand Down Expand Up @@ -434,7 +434,7 @@ public void testScanResistance() throws Exception {

DefaultConfiguration dc = DefaultConfiguration.getInstance();
ConfigurationCopy cc = new ConfigurationCopy(dc);
cc.set(Property.TSERV_CACHE_MANAGER_IMPL, LruBlockCacheManager.class.getName());
cc.set(Property.GENERAL_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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public void openReader(boolean cfsi) throws IOException {

DefaultConfiguration dc = DefaultConfiguration.getInstance();
ConfigurationCopy cc = new ConfigurationCopy(dc);
cc.set(Property.TSERV_CACHE_MANAGER_IMPL, LruBlockCacheManager.class.getName());
cc.set(Property.GENERAL_CACHE_MANAGER_IMPL, LruBlockCacheManager.class.getName());
try {
manager = BlockCacheManagerFactory.getInstance(cc);
} catch (Exception e) {
Expand Down Expand Up @@ -1726,7 +1726,7 @@ private void runVersionTest(int version, ConfigurationCopy aconf) throws Excepti
byte[] data = baos.toByteArray();
SeekableByteArrayInputStream bais = new SeekableByteArrayInputStream(data);
FSDataInputStream in2 = new FSDataInputStream(bais);
aconf.set(Property.TSERV_CACHE_MANAGER_IMPL, LruBlockCacheManager.class.getName());
aconf.set(Property.GENERAL_CACHE_MANAGER_IMPL, LruBlockCacheManager.class.getName());
aconf.set(Property.TSERV_DEFAULT_BLOCKSIZE, Long.toString(100000));
aconf.set(Property.TSERV_DATACACHE_SIZE, Long.toString(100000000));
aconf.set(Property.TSERV_INDEXCACHE_SIZE, Long.toString(100000000));
Expand Down

0 comments on commit 9e40a1e

Please sign in to comment.