HBASE-5641 decayingSampleTick1 prevents HBase from shutting down.
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1305722 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3fd6997380
commit
ef65dde6b3
|
@ -22,12 +22,12 @@ import java.util.Random;
|
|||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
import org.apache.hadoop.hbase.util.Threads;
|
||||
|
||||
/**
|
||||
* An exponentially-decaying random sample of {@code long}s.
|
||||
* Uses Cormode et al's forward-decaying priority reservoir sampling method
|
||||
|
@ -44,7 +44,7 @@ public class ExponentiallyDecayingSample implements Sample {
|
|||
|
||||
private static final ScheduledExecutorService TICK_SERVICE =
|
||||
Executors.newScheduledThreadPool(1,
|
||||
Threads.getNamedThreadFactory("decayingSampleTick"));
|
||||
getNamedDaemonThreadFactory("decayingSampleTick"));
|
||||
|
||||
private static volatile long CURRENT_TICK =
|
||||
TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());
|
||||
|
@ -209,4 +209,18 @@ public class ExponentiallyDecayingSample implements Sample {
|
|||
private void unlockForRegularUsage() {
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
|
||||
private static ThreadFactory getNamedDaemonThreadFactory(final String prefix) {
|
||||
return new ThreadFactory() {
|
||||
|
||||
private final AtomicInteger threadNumber = new AtomicInteger(1);
|
||||
|
||||
@Override
|
||||
public Thread newThread(Runnable r) {
|
||||
Thread t= new Thread(r, prefix + threadNumber.getAndIncrement());
|
||||
t.setDaemon(true);
|
||||
return t;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue