This is an automated email from the ASF dual-hosted git repository.

dlmarion pushed a commit to branch elasticity
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/elasticity by this push:
     new 7ea10de6c8 Refactor classes to use the Caches object (#4359)
7ea10de6c8 is described below

commit 7ea10de6c8af6a8c79e0ae6aadcc491566e75cee
Author: Dave Marion <dlmar...@apache.org>
AuthorDate: Tue Mar 12 08:10:10 2024 -0400

    Refactor classes to use the Caches object (#4359)
---
 .../java/org/apache/accumulo/core/util/cache/Caches.java   |  7 ++++++-
 .../accumulo/server/compaction/CompactionJobGenerator.java |  4 ++--
 .../accumulo/server/conf/ServerConfigurationFactory.java   | 14 ++++++++------
 .../org/apache/accumulo/server/fs/VolumeManagerImpl.java   |  6 ++++--
 4 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/core/src/main/java/org/apache/accumulo/core/util/cache/Caches.java 
b/core/src/main/java/org/apache/accumulo/core/util/cache/Caches.java
index a96af36bc5..f5ef8e4c8f 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/cache/Caches.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/cache/Caches.java
@@ -42,12 +42,14 @@ public class Caches implements MetricsProducer {
     COMPACTION_CONFIGS,
     COMPACTION_DIR_CACHE,
     COMPACTION_DISPATCHERS,
+    COMPACTION_SERVICE_UNKNOWN,
     COMPACTOR_GROUP_ID,
     COMPRESSION_ALGORITHM,
     CRYPT_PASSWORDS,
     HOST_REGEX_BALANCER_TABLE_REGEX,
     INSTANCE_ID,
     NAMESPACE_ID,
+    NAMESPACE_CONFIGS,
     PROP_CACHE,
     RECOVERY_MANAGER_PATH_CACHE,
     SCAN_SERVER_TABLET_METADATA,
@@ -56,10 +58,13 @@ public class Caches implements MetricsProducer {
     SPLITTER_FILES,
     SPLITTER_STARTING,
     SPLITTER_UNSPLITTABLE,
+    TABLE_CONFIGS,
     TABLE_ID,
+    TABLE_PARENT_CONFIGS,
     TABLE_ZOO_HELPER_CACHE,
     TSRM_FILE_LENGTHS,
-    TINYLFU_BLOCK_CACHE;
+    TINYLFU_BLOCK_CACHE,
+    VOLUME_HDFS_CONFIGS;
   }
 
   private static final Logger LOG = LoggerFactory.getLogger(Caches.class);
diff --git 
a/server/base/src/main/java/org/apache/accumulo/server/compaction/CompactionJobGenerator.java
 
b/server/base/src/main/java/org/apache/accumulo/server/compaction/CompactionJobGenerator.java
index 02e3dc2fca..1d88de2eaa 100644
--- 
a/server/base/src/main/java/org/apache/accumulo/server/compaction/CompactionJobGenerator.java
+++ 
b/server/base/src/main/java/org/apache/accumulo/server/compaction/CompactionJobGenerator.java
@@ -55,7 +55,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.github.benmanes.caffeine.cache.Cache;
-import com.github.benmanes.caffeine.cache.Caffeine;
 
 public class CompactionJobGenerator {
   private static final Logger log = 
LoggerFactory.getLogger(CompactionJobGenerator.class);
@@ -86,7 +85,8 @@ public class CompactionJobGenerator {
           v.isEmpty() ? Map.of() : Collections.unmodifiableMap(v)));
     }
     unknownCompactionServiceErrorCache =
-        Caffeine.newBuilder().expireAfterWrite(5, TimeUnit.MINUTES).build();
+        
Caches.getInstance().createNewBuilder(CacheName.COMPACTION_SERVICE_UNKNOWN, 
false)
+            .expireAfterWrite(5, TimeUnit.MINUTES).build();
   }
 
   public Collection<CompactionJob> generateJobs(TabletMetadata tablet, 
Set<CompactionKind> kinds) {
diff --git 
a/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java
 
b/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java
index 78b1e4f18b..c6f32946c3 100644
--- 
a/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java
+++ 
b/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java
@@ -36,6 +36,8 @@ import org.apache.accumulo.core.conf.DefaultConfiguration;
 import org.apache.accumulo.core.conf.SiteConfiguration;
 import org.apache.accumulo.core.data.NamespaceId;
 import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.util.cache.Caches;
+import org.apache.accumulo.core.util.cache.Caches.CacheName;
 import org.apache.accumulo.core.util.threads.ThreadPools;
 import org.apache.accumulo.core.util.threads.Threads;
 import org.apache.accumulo.server.ServerContext;
@@ -49,7 +51,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.github.benmanes.caffeine.cache.Cache;
-import com.github.benmanes.caffeine.cache.Caffeine;
 
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 
@@ -80,11 +81,12 @@ public class ServerConfigurationFactory extends 
ServerConfiguration {
     this.systemConfig = memoize(() -> new SystemConfiguration(context,
         SystemPropKey.of(context.getInstanceID()), siteConfig));
     tableParentConfigs =
-        Caffeine.newBuilder().expireAfterAccess(CACHE_EXPIRATION_HRS, 
TimeUnit.HOURS).build();
-    tableConfigs =
-        Caffeine.newBuilder().expireAfterAccess(CACHE_EXPIRATION_HRS, 
TimeUnit.HOURS).build();
-    namespaceConfigs =
-        Caffeine.newBuilder().expireAfterAccess(CACHE_EXPIRATION_HRS, 
TimeUnit.HOURS).build();
+        Caches.getInstance().createNewBuilder(CacheName.TABLE_PARENT_CONFIGS, 
false)
+            .expireAfterAccess(CACHE_EXPIRATION_HRS, TimeUnit.HOURS).build();
+    tableConfigs = 
Caches.getInstance().createNewBuilder(CacheName.TABLE_CONFIGS, false)
+        .expireAfterAccess(CACHE_EXPIRATION_HRS, TimeUnit.HOURS).build();
+    namespaceConfigs = 
Caches.getInstance().createNewBuilder(CacheName.NAMESPACE_CONFIGS, false)
+        .expireAfterAccess(CACHE_EXPIRATION_HRS, TimeUnit.HOURS).build();
 
     refresher = new ConfigRefreshRunner();
     Runtime.getRuntime()
diff --git 
a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java
 
b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java
index 1c1e7a4fd5..7607d5ceb9 100644
--- 
a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java
+++ 
b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java
@@ -47,6 +47,8 @@ import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.fate.FateId;
 import org.apache.accumulo.core.spi.fs.VolumeChooser;
 import org.apache.accumulo.core.util.Pair;
+import org.apache.accumulo.core.util.cache.Caches;
+import org.apache.accumulo.core.util.cache.Caches.CacheName;
 import org.apache.accumulo.core.util.threads.ThreadPools;
 import org.apache.accumulo.core.volume.Volume;
 import org.apache.accumulo.core.volume.VolumeConfiguration;
@@ -70,7 +72,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.github.benmanes.caffeine.cache.Cache;
-import com.github.benmanes.caffeine.cache.Caffeine;
 import com.google.common.collect.HashMultimap;
 import com.google.common.collect.Multimap;
 
@@ -81,7 +82,8 @@ public class VolumeManagerImpl implements VolumeManager {
   private static final HashSet<String> WARNED_ABOUT_SYNCONCLOSE = new 
HashSet<>();
 
   private static final Cache<Pair<Configuration,String>,Configuration> 
HDFS_CONFIGS_FOR_VOLUME =
-      Caffeine.newBuilder().expireAfterWrite(24, TimeUnit.HOURS).build();
+      Caches.getInstance().createNewBuilder(CacheName.VOLUME_HDFS_CONFIGS, 
false)
+          .expireAfterWrite(24, TimeUnit.HOURS).build();
 
   private final Map<String,Volume> volumesByName;
   private final Multimap<URI,Volume> volumesByFileSystemUri;

Reply via email to