YARN-8632. Threads in SLS quit without logging exception. Contributed by Xianghao Lu.

This commit is contained in:
Yufei Gu 2018-08-24 11:23:17 -07:00
parent 138b0c1443
commit 8563fd67be

View File

@ -32,7 +32,6 @@
import java.util.SortedMap;
import java.util.Locale;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.Lock;
@ -48,6 +47,7 @@
import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.util.ReflectionUtils;
import org.apache.hadoop.util.concurrent.HadoopScheduledThreadPoolExecutor;
import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.AbstractYarnScheduler;
@ -169,7 +169,7 @@ void init(ResourceScheduler resourceScheduler, Configuration config)
web.start();
// a thread to update histogram timer
pool = new ScheduledThreadPoolExecutor(2);
pool = new HadoopScheduledThreadPoolExecutor(2);
pool.scheduleAtFixedRate(new HistogramsRunnable(), 0, 1000,
TimeUnit.MILLISECONDS);
@ -518,7 +518,8 @@ class MetricsLogRunnable implements Runnable {
@Override
public void run() {
if(running) {
SchedulerWrapper wrapper = (SchedulerWrapper) scheduler;
if(running && wrapper.getTracker().getQueueSet() != null) {
// all WebApp to get real tracking json
String trackingMetrics = web.generateRealTimeTrackingMetrics();
// output