HBASE-17006 Give name to existing threads.
Having thread names in logs and thread dumps greatly improve debugability. This patch is simply adding the names to the threads we spawn. Change-Id: I6ff22cc3804bb81147dde3a8e9ab671633c6f6ce
This commit is contained in:
parent
f61ae6f06d
commit
bb0fc6b602
|
@ -113,7 +113,7 @@ public class PolicyBasedChaosMonkey extends ChaosMonkey {
|
||||||
|
|
||||||
for (int i=0; i<policies.length; i++) {
|
for (int i=0; i<policies.length; i++) {
|
||||||
policies[i].init(new Policy.PolicyContext(this.util));
|
policies[i].init(new Policy.PolicyContext(this.util));
|
||||||
Thread monkeyThread = new Thread(policies[i]);
|
Thread monkeyThread = new Thread(policies[i], "ChaosMonkeyThread");
|
||||||
monkeyThread.start();
|
monkeyThread.start();
|
||||||
monkeyThreads[i] = monkeyThread;
|
monkeyThreads[i] = monkeyThread;
|
||||||
}
|
}
|
||||||
|
|
|
@ -273,7 +273,7 @@ public class HFileSystem extends FilterFileSystem {
|
||||||
ClientProtocol cp1 = createReorderingProxy(namenode, lrb, conf);
|
ClientProtocol cp1 = createReorderingProxy(namenode, lrb, conf);
|
||||||
nf.set(dfsc, cp1);
|
nf.set(dfsc, cp1);
|
||||||
LOG.info("Added intercepting call to namenode#getBlockLocations so can do block reordering" +
|
LOG.info("Added intercepting call to namenode#getBlockLocations so can do block reordering" +
|
||||||
" using class " + lrb.getClass());
|
" using class " + lrb.getClass().getName());
|
||||||
} catch (NoSuchFieldException e) {
|
} catch (NoSuchFieldException e) {
|
||||||
LOG.warn("Can't modify the DFSClient#namenode field to add the location reorder.", e);
|
LOG.warn("Can't modify the DFSClient#namenode field to add the location reorder.", e);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -63,8 +63,8 @@ public class PrefetchExecutor {
|
||||||
new ThreadFactory() {
|
new ThreadFactory() {
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable r) {
|
public Thread newThread(Runnable r) {
|
||||||
Thread t = new Thread(r);
|
String name = "hfile-prefetch-" + System.currentTimeMillis();
|
||||||
t.setName("hfile-prefetch-" + System.currentTimeMillis());
|
Thread t = new Thread(r, name);
|
||||||
t.setDaemon(true);
|
t.setDaemon(true);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
|
@ -784,6 +784,7 @@ public class BucketCache implements BlockCache, HeapSize {
|
||||||
private volatile boolean writerEnabled = true;
|
private volatile boolean writerEnabled = true;
|
||||||
|
|
||||||
WriterThread(BlockingQueue<RAMQueueEntry> queue) {
|
WriterThread(BlockingQueue<RAMQueueEntry> queue) {
|
||||||
|
super("BucketCacheWriterThread");
|
||||||
this.inputQueue = queue;
|
this.inputQueue = queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -666,7 +666,8 @@ public class HMaster extends HRegionServer implements MasterServices {
|
||||||
throws IOException, InterruptedException, KeeperException, CoordinatedStateException {
|
throws IOException, InterruptedException, KeeperException, CoordinatedStateException {
|
||||||
|
|
||||||
isActiveMaster = true;
|
isActiveMaster = true;
|
||||||
Thread zombieDetector = new Thread(new InitializationMonitor(this));
|
Thread zombieDetector = new Thread(new InitializationMonitor(this),
|
||||||
|
"ActiveMasterInitializationMonitor-" + System.currentTimeMillis());
|
||||||
zombieDetector.start();
|
zombieDetector.start();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -57,9 +57,8 @@ public class MasterMobCompactionThread {
|
||||||
new SynchronousQueue<Runnable>(), new ThreadFactory() {
|
new SynchronousQueue<Runnable>(), new ThreadFactory() {
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable r) {
|
public Thread newThread(Runnable r) {
|
||||||
Thread t = new Thread(r);
|
String name = n + "-MasterMobCompaction-" + EnvironmentEdgeManager.currentTime();
|
||||||
t.setName(n + "-MasterMobCompaction-" + EnvironmentEdgeManager.currentTime());
|
return new Thread(r, name);
|
||||||
return t;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
((ThreadPoolExecutor) this.masterMobPool).allowCoreThreadTimeOut(true);
|
((ThreadPoolExecutor) this.masterMobPool).allowCoreThreadTimeOut(true);
|
||||||
|
|
|
@ -124,9 +124,8 @@ public class CompactSplitThread implements CompactionRequestor, PropagatingConfi
|
||||||
new ThreadFactory() {
|
new ThreadFactory() {
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable r) {
|
public Thread newThread(Runnable r) {
|
||||||
Thread t = new Thread(r);
|
String name = n + "-longCompactions-" + System.currentTimeMillis();
|
||||||
t.setName(n + "-longCompactions-" + System.currentTimeMillis());
|
return new Thread(r, name);
|
||||||
return t;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.longCompactions.setRejectedExecutionHandler(new Rejection());
|
this.longCompactions.setRejectedExecutionHandler(new Rejection());
|
||||||
|
@ -136,9 +135,8 @@ public class CompactSplitThread implements CompactionRequestor, PropagatingConfi
|
||||||
new ThreadFactory() {
|
new ThreadFactory() {
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable r) {
|
public Thread newThread(Runnable r) {
|
||||||
Thread t = new Thread(r);
|
String name = n + "-shortCompactions-" + System.currentTimeMillis();
|
||||||
t.setName(n + "-shortCompactions-" + System.currentTimeMillis());
|
return new Thread(r, name);
|
||||||
return t;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.shortCompactions
|
this.shortCompactions
|
||||||
|
@ -148,9 +146,8 @@ public class CompactSplitThread implements CompactionRequestor, PropagatingConfi
|
||||||
new ThreadFactory() {
|
new ThreadFactory() {
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable r) {
|
public Thread newThread(Runnable r) {
|
||||||
Thread t = new Thread(r);
|
String name = n + "-splits-" + System.currentTimeMillis();
|
||||||
t.setName(n + "-splits-" + System.currentTimeMillis());
|
return new Thread(r, name);
|
||||||
return t;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
int mergeThreads = conf.getInt(MERGE_THREADS, MERGE_THREADS_DEFAULT);
|
int mergeThreads = conf.getInt(MERGE_THREADS, MERGE_THREADS_DEFAULT);
|
||||||
|
@ -158,9 +155,8 @@ public class CompactSplitThread implements CompactionRequestor, PropagatingConfi
|
||||||
mergeThreads, new ThreadFactory() {
|
mergeThreads, new ThreadFactory() {
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable r) {
|
public Thread newThread(Runnable r) {
|
||||||
Thread t = new Thread(r);
|
String name = n + "-merges-" + System.currentTimeMillis();
|
||||||
t.setName(n + "-merges-" + System.currentTimeMillis());
|
return new Thread(r, name);
|
||||||
return t;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -504,9 +504,6 @@ public class HRegionServer extends HasThread implements
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts a HRegionServer at the default location.
|
* Starts a HRegionServer at the default location.
|
||||||
* @param conf
|
|
||||||
* @throws IOException
|
|
||||||
* @throws InterruptedException
|
|
||||||
*/
|
*/
|
||||||
public HRegionServer(Configuration conf) throws IOException, InterruptedException {
|
public HRegionServer(Configuration conf) throws IOException, InterruptedException {
|
||||||
this(conf, CoordinatedStateManagerFactory.getCoordinatedStateManager(conf));
|
this(conf, CoordinatedStateManagerFactory.getCoordinatedStateManager(conf));
|
||||||
|
@ -514,12 +511,10 @@ public class HRegionServer extends HasThread implements
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts a HRegionServer at the default location
|
* Starts a HRegionServer at the default location
|
||||||
* @param conf
|
|
||||||
* @param csm implementation of CoordinatedStateManager to be used
|
* @param csm implementation of CoordinatedStateManager to be used
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
public HRegionServer(Configuration conf, CoordinatedStateManager csm)
|
public HRegionServer(Configuration conf, CoordinatedStateManager csm) throws IOException {
|
||||||
throws IOException {
|
super("RegionServer"); // thread name
|
||||||
this.fsOk = true;
|
this.fsOk = true;
|
||||||
this.conf = conf;
|
this.conf = conf;
|
||||||
HFile.checkHFileVersion(this.conf);
|
HFile.checkHFileVersion(this.conf);
|
||||||
|
|
|
@ -68,6 +68,7 @@ public class Leases extends HasThread {
|
||||||
* (milliseconds)
|
* (milliseconds)
|
||||||
*/
|
*/
|
||||||
public Leases(final int leaseCheckFrequency) {
|
public Leases(final int leaseCheckFrequency) {
|
||||||
|
super("RegionServerLeases"); // thread name
|
||||||
this.leaseCheckFrequency = leaseCheckFrequency;
|
this.leaseCheckFrequency = leaseCheckFrequency;
|
||||||
setDaemon(true);
|
setDaemon(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class LogRoller extends HasThread {
|
||||||
|
|
||||||
/** @param server */
|
/** @param server */
|
||||||
public LogRoller(final Server server, final RegionServerServices services) {
|
public LogRoller(final Server server, final RegionServerServices services) {
|
||||||
super();
|
super("LogRoller");
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.services = services;
|
this.services = services;
|
||||||
this.rollperiod = this.server.getConfiguration().
|
this.rollperiod = this.server.getConfiguration().
|
||||||
|
|
|
@ -44,11 +44,9 @@ public class RegionServicesForStores {
|
||||||
new ThreadFactory() {
|
new ThreadFactory() {
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable r) {
|
public Thread newThread(Runnable r) {
|
||||||
Thread t = new Thread(r);
|
String name = Thread.currentThread().getName() + "-inmemoryCompactions-" +
|
||||||
t.setName(Thread.currentThread().getName()
|
System.currentTimeMillis();
|
||||||
+ "-inmemoryCompactions-"
|
return new Thread(r, name);
|
||||||
+ System.currentTimeMillis());
|
|
||||||
return t;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
private final HRegion region;
|
private final HRegion region;
|
||||||
|
|
|
@ -119,7 +119,8 @@ public class ShutdownHook {
|
||||||
if (refs == 1) {
|
if (refs == 1) {
|
||||||
LOG.info("Starting fs shutdown hook thread.");
|
LOG.info("Starting fs shutdown hook thread.");
|
||||||
Thread fsShutdownHookThread = (fsShutdownHook instanceof Thread) ?
|
Thread fsShutdownHookThread = (fsShutdownHook instanceof Thread) ?
|
||||||
(Thread)fsShutdownHook : new Thread(fsShutdownHook);
|
(Thread)fsShutdownHook : new Thread(fsShutdownHook,
|
||||||
|
fsShutdownHook.getClass().getSimpleName() + "-shutdown-hook");
|
||||||
fsShutdownHookThread.start();
|
fsShutdownHookThread.start();
|
||||||
Threads.shutdown(fsShutdownHookThread,
|
Threads.shutdown(fsShutdownHookThread,
|
||||||
this.conf.getLong(FS_SHUTDOWN_HOOK_WAIT, 30000));
|
this.conf.getLong(FS_SHUTDOWN_HOOK_WAIT, 30000));
|
||||||
|
|
|
@ -720,7 +720,7 @@ public final class Canary implements Tool {
|
||||||
// Do monitor !!
|
// Do monitor !!
|
||||||
try {
|
try {
|
||||||
monitor = this.newMonitor(connection, index, args);
|
monitor = this.newMonitor(connection, index, args);
|
||||||
monitorThread = new Thread(monitor);
|
monitorThread = new Thread(monitor, "CanaryMonitor-" + System.currentTimeMillis());
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
monitorThread.start();
|
monitorThread.start();
|
||||||
while (!monitor.isDone()) {
|
while (!monitor.isDone()) {
|
||||||
|
|
|
@ -83,9 +83,8 @@ public class JvmPauseMonitor {
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
Preconditions.checkState(monitorThread == null, "Already started");
|
Preconditions.checkState(monitorThread == null, "Already started");
|
||||||
monitorThread = new Thread(new Monitor());
|
monitorThread = new Thread(new Monitor(), "JvmPauseMonitor");
|
||||||
monitorThread.setDaemon(true);
|
monitorThread.setDaemon(true);
|
||||||
monitorThread.setName("JvmPauseMonitor");
|
|
||||||
monitorThread.start();
|
monitorThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -233,8 +233,7 @@ public abstract class ModifyRegionUtils {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Thread newThread(Runnable r) {
|
public Thread newThread(Runnable r) {
|
||||||
Thread t = new Thread(r, threadNamePrefix + "-" + count++);
|
return new Thread(r, threadNamePrefix + "-" + count++);
|
||||||
return t;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return regionOpenAndInitThreadPool;
|
return regionOpenAndInitThreadPool;
|
||||||
|
|
|
@ -69,9 +69,7 @@ public class PerformanceEvaluationCommons {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
List<Thread> threads = new ArrayList<Thread>(count);
|
List<Thread> threads = new ArrayList<Thread>(count);
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
Thread t = new Thread(r);
|
threads.add(new Thread(r, "concurrentRead-" + i));
|
||||||
t.setName("" + i);
|
|
||||||
threads.add(t);
|
|
||||||
}
|
}
|
||||||
for (Thread t: threads) {
|
for (Thread t: threads) {
|
||||||
t.start();
|
t.start();
|
||||||
|
|
|
@ -158,7 +158,8 @@ public abstract class MultiThreadedAction {
|
||||||
this.startKey = startKey;
|
this.startKey = startKey;
|
||||||
this.endKey = endKey;
|
this.endKey = endKey;
|
||||||
this.numThreads = numThreads;
|
this.numThreads = numThreads;
|
||||||
(new Thread(new ProgressReporter(actionLetter))).start();
|
(new Thread(new ProgressReporter(actionLetter),
|
||||||
|
"MultiThreadedAction-ProgressReporter-" + System.currentTimeMillis())).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String formatTime(long elapsedTime) {
|
private static String formatTime(long elapsedTime) {
|
||||||
|
|
|
@ -89,7 +89,8 @@ public abstract class MultiThreadedWriterBase extends MultiThreadedAction {
|
||||||
wroteUpToKey.set(startKey - 1);
|
wroteUpToKey.set(startKey - 1);
|
||||||
|
|
||||||
if (trackWroteKeys) {
|
if (trackWroteKeys) {
|
||||||
new Thread(new WroteKeysTracker()).start();
|
new Thread(new WroteKeysTracker(),
|
||||||
|
"MultiThreadedWriterBase-WroteKeysTracker-" + System.currentTimeMillis()).start();
|
||||||
numThreadsWorking.incrementAndGet();
|
numThreadsWorking.incrementAndGet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue