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



##########
File path: 
core/src/main/java/org/apache/accumulo/core/clientImpl/TabletServerBatchWriter.java
##########
@@ -571,13 +570,17 @@ private synchronized void addFailedMutations(MutationSet 
failedMutations) {
     }
   }
 
-  private class FailedMutations extends TimerTask {
+  private class FailedMutations {
 
     private MutationSet recentFailures = null;
     private long initTime;
+    private final Runnable task;
 
     FailedMutations() {
-      jtimer.schedule(this, 0, 500);
+      task = Threads.createNamedRunnable("failed 
mutationBatchWriterLatencyTimers handler", () -> {
+        run();
+      });

Review comment:
       Would this work?
   
   ```suggestion
         task = Threads.createNamedRunnable("failed 
mutationBatchWriterLatencyTimers handler", this::run);
   ```

##########
File path: 
core/src/main/java/org/apache/accumulo/core/classloader/DefaultContextClassLoaderFactory.java
##########
@@ -59,18 +60,20 @@ 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 cc = new 
ConfigurationCopy(contextConfigSupplier.get());
+    String size = cc.get(Property.GENERAL_SIMPLETIMER_THREADPOOL_SIZE);
+    if (null == size || size.isEmpty()) {
+      cc.set(Property.GENERAL_SIMPLETIMER_THREADPOOL_SIZE,
+          Property.GENERAL_SIMPLETIMER_THREADPOOL_SIZE.getDefaultValue());
+    }
+    ThreadPools.createGeneralScheduledExecutorService(cc)
+        .scheduleWithFixedDelay(Threads.createNamedRunnable(className + 
"-cleanup", () -> {
+          LOG.trace("{}-cleanup thread, properties: {}", className, cc);
+          Set<String> contextsInUse = cc
+              
.getAllPropertiesWithPrefixStripped(Property.VFS_CONTEXT_CLASSPATH_PROPERTY).keySet();

Review comment:
       This updates the context using the ConfigurationCopy instead of the 
contextConfigSupplier, which would provide it on-demand. Using the 
ConfigurationCopy means it will get the same initial value every time the 
thread executes, and will never see the updated value of 
`VFS_CONTEXT_CLASSPATH_PROPERTY` if it changes.

##########
File path: core/src/main/java/org/apache/accumulo/core/util/Halt.java
##########
@@ -51,9 +50,10 @@ 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() {
+      new Thread() {
         @Override
         public void run() {
+          setDaemon(true);

Review comment:
       Is it legal to switch to a Daemon thread after it has already started 
executing? Will this have any effect?




----------------------------------------------------------------
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