HDFS-16033 Fix issue of the StatisticsDataReferenceCleaner cleanUp (#3042)

Contributed by kaifeiYi (yikf).

Signed-off-by: Mingliang Liu <liuml07@apache.org>
Reviewed-by: Steve Loughran <stevel@apache.org>
This commit is contained in:
July 2021-06-05 04:36:09 +08:00 committed by Mingliang Liu
parent ede03cc35c
commit 8c0f948054
No known key found for this signature in database
GPG Key ID: BC2FB8C6908A0C16

View File

@ -4013,12 +4013,19 @@ public void cleanUp() {
* Background action to act on references being removed.
*/
private static class StatisticsDataReferenceCleaner implements Runnable {
/**
* Represents the timeout period expires for remove reference objects from
* the STATS_DATA_REF_QUEUE when the queue is empty.
*/
private static final int REF_QUEUE_POLL_TIMEOUT = 10000;
@Override
public void run() {
while (!Thread.interrupted()) {
try {
StatisticsDataReference ref =
(StatisticsDataReference)STATS_DATA_REF_QUEUE.remove();
(StatisticsDataReference)STATS_DATA_REF_QUEUE.
remove(REF_QUEUE_POLL_TIMEOUT);
ref.cleanUp();
} catch (InterruptedException ie) {
LOGGER.warn("Cleaner thread interrupted, will stop", ie);