mirror of https://github.com/apache/druid.git
Make forking task runner have more informative thread names during the long-blocking part (#3172)
* Make forking task runner have more informative thread names during the long-blocking part * Make string.format do the work
This commit is contained in:
parent
15f833a861
commit
6be18376c0
|
@ -428,6 +428,11 @@ public class ForkingTaskRunner implements TaskRunner, TaskLogStreamer
|
||||||
boolean runFailed = true;
|
boolean runFailed = true;
|
||||||
|
|
||||||
final ByteSink logSink = Files.asByteSink(logFile, FileWriteMode.APPEND);
|
final ByteSink logSink = Files.asByteSink(logFile, FileWriteMode.APPEND);
|
||||||
|
|
||||||
|
// This will block for a while. So we append the thread information with more details
|
||||||
|
final String priorThreadName = Thread.currentThread().getName();
|
||||||
|
Thread.currentThread().setName(String.format("%s-[%s]", priorThreadName, task.getId()));
|
||||||
|
|
||||||
try (final OutputStream toLogfile = logSink.openStream()) {
|
try (final OutputStream toLogfile = logSink.openStream()) {
|
||||||
ByteStreams.copy(processHolder.process.getInputStream(), toLogfile);
|
ByteStreams.copy(processHolder.process.getInputStream(), toLogfile);
|
||||||
final int statusCode = processHolder.process.waitFor();
|
final int statusCode = processHolder.process.waitFor();
|
||||||
|
@ -437,6 +442,7 @@ public class ForkingTaskRunner implements TaskRunner, TaskLogStreamer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
Thread.currentThread().setName(priorThreadName);
|
||||||
// Upload task logs
|
// Upload task logs
|
||||||
taskLogPusher.pushTaskLog(task.getId(), logFile);
|
taskLogPusher.pushTaskLog(task.getId(), logFile);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue