Skip to content

Commit

Permalink
Name threads used by LocalCacheManager
Browse files Browse the repository at this point in the history
### What changes are proposed in this pull request?

Using name threads is generally a good practice and helps system administrators understand what's going on with the system. Without explicit naming, the JDK-provided pools jave threads named `pool-N-thread-T`.


			pr-link: #18573
			change-id: cid-2fb9e71b75de62e7c6a0ead8c83037922957bf68
  • Loading branch information
findepi authored Apr 11, 2024
1 parent 6e5a618 commit 36b0b16
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import alluxio.metrics.MultiDimensionalMetricsSystem;
import alluxio.network.protocol.databuffer.DataFileChannel;
import alluxio.resource.LockResource;
import alluxio.util.ThreadFactoryUtils;

import com.codahale.metrics.Counter;
import com.google.common.annotations.VisibleForTesting;
Expand Down Expand Up @@ -158,10 +159,13 @@ public static LocalCacheManager create(CacheManagerOptions options,
options.isAsyncWriteEnabled()
? Optional.of(new ThreadPoolExecutor(mOptions.getAsyncWriteThreads(),
mOptions.getAsyncWriteThreads(), 60, TimeUnit.SECONDS,
new SynchronousQueue<>(), new ThreadPoolExecutor.CallerRunsPolicy()))
new SynchronousQueue<>(), ThreadFactoryUtils.build(
"alluxio-async-cache-executor", true),
new ThreadPoolExecutor.CallerRunsPolicy()))
: Optional.empty();
mInitService =
options.isAsyncRestoreEnabled() ? Optional.of(Executors.newSingleThreadExecutor()) :
options.isAsyncRestoreEnabled() ? Optional.of(Executors.newSingleThreadExecutor(
ThreadFactoryUtils.build("alluxio-init-service", true))) :
Optional.empty();
if (options.isTtlEnabled()) {
Predicate<PageInfo> ttl = pageInfo -> {
Expand All @@ -174,7 +178,8 @@ public static LocalCacheManager create(CacheManagerOptions options,
}
};
mPagePredicate = Optional.of(ttl);
mTtlEnforcerExecutor = Optional.of(newScheduledThreadPool(1));
mTtlEnforcerExecutor = Optional.of(newScheduledThreadPool(1,
ThreadFactoryUtils.build("alluxio-ttl-executor", true)));
mTtlEnforcerExecutor.get().scheduleAtFixedRate(() ->
LocalCacheManager.this.invalidate(ttl), 0, options.getTtlCheckIntervalSeconds(), SECONDS);
} else {
Expand Down

0 comments on commit 36b0b16

Please sign in to comment.