ctubbsii commented on a change in pull request #1818:
URL: https://github.com/apache/accumulo/pull/1818#discussion_r556578502



##########
File path: 
core/src/main/java/org/apache/accumulo/core/classloader/DefaultContextClassLoaderFactory.java
##########
@@ -59,18 +60,23 @@ public DefaultContextClassLoaderFactory(final 
AccumuloConfiguration accConf) {
   }
 
   private static void startCleanupThread(final Supplier<Map<String,String>> 
contextConfigSupplier) {
-    new Timer(className + "-cleanup", true).scheduleAtFixedRate(new 
TimerTask() {
-      @Override
-      public void run() {
-        Map<String,String> contextConfigs = contextConfigSupplier.get();
-        LOG.trace("{}-cleanup thread, properties: {}", className, 
contextConfigs);
-        int prefixlen = 
Property.VFS_CONTEXT_CLASSPATH_PROPERTY.getKey().length();
-        Set<String> contextsInUse = contextConfigs.keySet().stream()
-            .map(k -> k.substring(prefixlen)).collect(Collectors.toSet());
-        LOG.trace("{}-cleanup thread, contexts in use: {}", className, 
contextsInUse);
-        AccumuloVFSClassLoader.removeUnusedContexts(contextsInUse);
-      }
-    }, 60_000, 60_000);
+    final ConfigurationCopy threadPoolProperties =
+        new ConfigurationCopy(contextConfigSupplier.get());
+    String size = 
threadPoolProperties.get(Property.GENERAL_SIMPLETIMER_THREADPOOL_SIZE);
+    if (null == size || size.isEmpty()) {
+      threadPoolProperties.set(Property.GENERAL_SIMPLETIMER_THREADPOOL_SIZE,
+          Property.GENERAL_SIMPLETIMER_THREADPOOL_SIZE.getDefaultValue());
+    }

Review comment:
       Reading properties other than those that start with the 
VFS_CONTEXT_CLASSPATH_PROPERTY won't work here, because the 
contextConfigSupplier already filters out all other properties. So, you can't 
read the SIMPLETIMER properties from this map.

##########
File path: 
core/src/main/java/org/apache/accumulo/core/classloader/DefaultContextClassLoaderFactory.java
##########
@@ -59,18 +60,23 @@ public DefaultContextClassLoaderFactory(final 
AccumuloConfiguration accConf) {
   }
 
   private static void startCleanupThread(final Supplier<Map<String,String>> 
contextConfigSupplier) {
-    new Timer(className + "-cleanup", true).scheduleAtFixedRate(new 
TimerTask() {
-      @Override
-      public void run() {
-        Map<String,String> contextConfigs = contextConfigSupplier.get();
-        LOG.trace("{}-cleanup thread, properties: {}", className, 
contextConfigs);
-        int prefixlen = 
Property.VFS_CONTEXT_CLASSPATH_PROPERTY.getKey().length();
-        Set<String> contextsInUse = contextConfigs.keySet().stream()
-            .map(k -> k.substring(prefixlen)).collect(Collectors.toSet());
-        LOG.trace("{}-cleanup thread, contexts in use: {}", className, 
contextsInUse);
-        AccumuloVFSClassLoader.removeUnusedContexts(contextsInUse);
-      }
-    }, 60_000, 60_000);
+    final ConfigurationCopy threadPoolProperties =
+        new ConfigurationCopy(contextConfigSupplier.get());
+    String size = 
threadPoolProperties.get(Property.GENERAL_SIMPLETIMER_THREADPOOL_SIZE);
+    if (null == size || size.isEmpty()) {
+      threadPoolProperties.set(Property.GENERAL_SIMPLETIMER_THREADPOOL_SIZE,
+          Property.GENERAL_SIMPLETIMER_THREADPOOL_SIZE.getDefaultValue());
+    }
+    ThreadPools.createGeneralScheduledExecutorService(threadPoolProperties)
+        .scheduleWithFixedDelay(Threads.createNamedRunnable(className + 
"-cleanup", () -> {
+          ConfigurationCopy contextCleanerProperties =
+              new ConfigurationCopy(contextConfigSupplier.get());
+          LOG.trace("{}-cleanup thread, properties: {}", className, 
threadPoolProperties);
+          Set<String> contextsInUse = contextCleanerProperties
+              
.getAllPropertiesWithPrefixStripped(Property.VFS_CONTEXT_CLASSPATH_PROPERTY).keySet();

Review comment:
       Placing it in a new ConfigurationCopy to use the method that strips the 
property prefix out seems a bit more work than the old code did. The 
contextConfigSupplier already filters matching items, so all we need to do is 
strip out the prefix. We can avoid creating a new ConfigurationCopy object for 
this.

##########
File path: core/src/main/java/org/apache/accumulo/core/util/Halt.java
##########
@@ -49,15 +49,16 @@ public void run() {
   }
 
   public static void halt(final int status, Runnable runnable) {
+
     try {
       // give ourselves a little time to try and do something
-      new Daemon() {
+      Threads.createThread("Halt Thread", new Runnable() {
         @Override
         public void run() {
           sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
           Runtime.getRuntime().halt(status);
         }
-      }.start();
+      }).start();

Review comment:
       With a lambda, this would be slightly shorter:
   
   ```java
         Threads.createThread("Halt Thread", () -> {
           sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
           Runtime.getRuntime().halt(status);
         }).start();
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to