Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,7 @@ public class BucketCache implements BlockCache, HeapSize {
});

/** Statistics thread schedule pool (for heavy debugging, could remove) */
private transient final ScheduledExecutorService scheduleThreadPool =
Executors.newScheduledThreadPool(1,
new ThreadFactoryBuilder().setNameFormat("BucketCacheStatsExecutor").setDaemon(true).build());
private final transient ScheduledExecutorService scheduleThreadPool;

// Allocate or free space for the block
private transient BucketAllocator bucketAllocator;
Expand All @@ -244,6 +242,8 @@ public class BucketCache implements BlockCache, HeapSize {
private static final String FILE_VERIFY_ALGORITHM =
"hbase.bucketcache.persistent.file.integrity.check.algorithm";
private static final String DEFAULT_FILE_VERIFY_ALGORITHM = "MD5";
private static final String STAT_THREAD_ENABLE_KEY = "hbase.bucketcache.stat.enable";
private static final boolean STAT_THREAD_ENABLE_DEFAULT = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And better set it to true to keep the old behavior by default?

Copy link
Contributor Author

@YutSean YutSean Jan 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose to make the log alternative is that the log is only used when heavy debugging is needed. Turn on is a little bit annoying at other time I think. So that I changed the old behaviour. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in this PR we'd better keep the old behavior, i.e, set it true. We can file another issue to change it to true on master branch, and mark it as incompatible change. On branch-2.x we'd better keep the old behavior.


/**
* Use {@link java.security.MessageDigest} class's encryption algorithms to check
Expand Down Expand Up @@ -325,11 +325,16 @@ public BucketCache(String ioEngineName, long capacity, int blockSize, int[] buck
}
startWriterThreads();

// Run the statistics thread periodically to print the cache statistics log
// TODO: Add means of turning this off. Bit obnoxious running thread just to make a log
// every five minutes.
this.scheduleThreadPool.scheduleAtFixedRate(new StatisticsThread(this),
// Run the statistics thread periodically to print the cache statistics log if it is enabled.
if (conf.getBoolean(STAT_THREAD_ENABLE_KEY, STAT_THREAD_ENABLE_DEFAULT)) {
this.scheduleThreadPool = Executors.newScheduledThreadPool(1,
new ThreadFactoryBuilder().setNameFormat("BucketCacheStatsExecutor").
setDaemon(true).build());
this.scheduleThreadPool.scheduleAtFixedRate(new StatisticsThread(this),
statThreadPeriod, statThreadPeriod, TimeUnit.SECONDS);
} else {
this.scheduleThreadPool = null;
}
LOG.info("Started bucket cache; ioengine=" + ioEngineName +
", capacity=" + StringUtils.byteDesc(capacity) +
", blockSize=" + StringUtils.byteDesc(blockSize) + ", writerThreadNum=" +
Expand Down Expand Up @@ -1316,7 +1321,9 @@ private void disableCache() {
if (!cacheEnabled) return;
cacheEnabled = false;
ioEngine.shutdown();
this.scheduleThreadPool.shutdown();
if (this.scheduleThreadPool != null) {
this.scheduleThreadPool.shutdown();
}
for (int i = 0; i < writerThreads.length; ++i) writerThreads[i].interrupt();
this.ramCache.clear();
if (!ioEngine.isPersistent() || persistencePath == null) {
Expand Down