YARN-10679. Better logging of uncaught exceptions throughout SLS. Contributed by Szilard Nemeth.

This commit is contained in:
Peter Bacsko 2021-03-09 14:02:12 +01:00
parent 099f58f8f4
commit c3aa413ee3
4 changed files with 17 additions and 10 deletions

View File

@ -63,7 +63,6 @@ import com.codahale.metrics.Timer;
@Unstable @Unstable
public class SLSCapacityScheduler extends CapacityScheduler implements public class SLSCapacityScheduler extends CapacityScheduler implements
SchedulerWrapper,Configurable { SchedulerWrapper,Configurable {
private Configuration conf; private Configuration conf;
private Map<ApplicationAttemptId, String> appQueueMap = private Map<ApplicationAttemptId, String> appQueueMap =
@ -99,7 +98,7 @@ public class SLSCapacityScheduler extends CapacityScheduler implements
CapacityScheduler.class); CapacityScheduler.class);
schedulerMetrics.init(this, conf); schedulerMetrics.init(this, conf);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); LOG.error("Caught exception while initializing schedulerMetrics", e);
} }
} }
} }
@ -129,7 +128,7 @@ public class SLSCapacityScheduler extends CapacityScheduler implements
updateQueueWithAllocateRequest(allocation, attemptId, updateQueueWithAllocateRequest(allocation, attemptId,
resourceRequests, containerIds); resourceRequests, containerIds);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); LOG.error("Caught exception while executing finally block", e);
} }
} }
} else { } else {
@ -376,7 +375,7 @@ public class SLSCapacityScheduler extends CapacityScheduler implements
schedulerMetrics.tearDown(); schedulerMetrics.tearDown();
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); LOG.error("Caught exception while stopping service", e);
} }
super.serviceStop(); super.serviceStop();
} }

View File

@ -92,7 +92,7 @@ public class SLSFairScheduler extends FairScheduler
FairScheduler.class); FairScheduler.class);
schedulerMetrics.init(this, conf); schedulerMetrics.init(this, conf);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); LOG.error("Caught exception while initializing schedulerMetrics", e);
} }
} }
} }
@ -122,7 +122,7 @@ public class SLSFairScheduler extends FairScheduler
updateQueueWithAllocateRequest(allocation, attemptId, updateQueueWithAllocateRequest(allocation, attemptId,
resourceRequests, containerIds); resourceRequests, containerIds);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); LOG.error("Caught exception while executing finally block", e);
} }
} }
} else { } else {
@ -332,7 +332,7 @@ public class SLSFairScheduler extends FairScheduler
schedulerMetrics.tearDown(); schedulerMetrics.tearDown();
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); LOG.error("Caught exception while stopping service", e);
} }
super.serviceStop(); super.serviceStop();
} }

View File

@ -26,10 +26,14 @@ import java.util.concurrent.TimeUnit;
import org.apache.hadoop.classification.InterfaceAudience.Private; import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Private @Private
@Unstable @Unstable
public class TaskRunner { public class TaskRunner {
private static final Logger LOG = LoggerFactory.getLogger(TaskRunner.class);
@Private @Private
@Unstable @Unstable
public abstract static class Task implements Runnable, Delayed { public abstract static class Task implements Runnable, Delayed {
@ -98,7 +102,7 @@ public class TaskRunner {
lastStep(); lastStep();
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); LOG.error("Caught exception while executing Taskrunner", e);
Thread.getDefaultUncaughtExceptionHandler() Thread.getDefaultUncaughtExceptionHandler()
.uncaughtException(Thread.currentThread(), e); .uncaughtException(Thread.currentThread(), e);
} }

View File

@ -50,10 +50,14 @@ import com.codahale.metrics.Counter;
import com.codahale.metrics.Gauge; import com.codahale.metrics.Gauge;
import com.codahale.metrics.Histogram; import com.codahale.metrics.Histogram;
import com.codahale.metrics.MetricRegistry; import com.codahale.metrics.MetricRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Private @Private
@Unstable @Unstable
public class SLSWebApp extends HttpServlet { public class SLSWebApp extends HttpServlet {
private static final Logger LOG = LoggerFactory.getLogger(SLSWebApp.class);
private static final long serialVersionUID = 1905162041950251407L; private static final long serialVersionUID = 1905162041950251407L;
private transient Server server; private transient Server server;
private transient SchedulerWrapper wrapper; private transient SchedulerWrapper wrapper;
@ -101,7 +105,7 @@ public class SLSWebApp extends HttpServlet {
trackTemplate = IOUtils.toString( trackTemplate = IOUtils.toString(
cl.getResourceAsStream("html/track.html.template"), StandardCharsets.UTF_8); cl.getResourceAsStream("html/track.html.template"), StandardCharsets.UTF_8);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); LOG.error("Caught exception while initializing templates", e);
} }
} }
@ -166,7 +170,7 @@ public class SLSWebApp extends HttpServlet {
printJsonTrack(request, response); printJsonTrack(request, response);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); LOG.error("Caught exception while starting SLSWebApp", e);
} }
} }
}; };