gpt4 book ai didi

hadoop - 检测YARN何时杀死容器

转载 作者:行者123 更新时间:2023-12-02 20:46:34 26 4
gpt4 key购买 nike

我在Java上有MR2工作。
是否可以检测并处理容器内的容器死亡?
我试图使用类似的代码

Runtime.getRuntime().addShutdownHook(new Hooker(this));

但是没有找到来自Hooker类实例的日志。
也许可以为此容器获取Java堆转储吗?

杀死原因是
Container [pid=35696,containerID=container_1509737408754_96482_01_000384] is running beyond physical memory limits. 
Current usage: 2.0 GB of 2 GB physical memory used; 3.6 GB of 4.2 GB virtual memory used. Killing container. Dump of the process-tree for container_1509737408754_96482_01_000384 : |- PID PPID PGRPID SESSID CMD_NAME USER_MODE_TIME(MILLIS) SYSTEM_TIME(MILLIS) VMEM_USAGE(BYTES) RSSMEM_USAGE(PAGES) FULL_CMD_LINE |- 35696 35694 35696 35696 (bash)

谢谢

最佳答案

您可以为此使用子进程,使用以下代码并添加过滤器以检测 yarn 杀死。

public class YarnLog {
//
public static void getYarnLog(String appid) throws IOException {
BufferedReader br = null;
try {
Process p = Runtime.getRuntime().exec(String.format("yarn logs -applicationId %s", appid));
br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while((line = br.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if(br != null) {
br.close();
}
}
}

}

关于hadoop - 检测YARN何时杀死容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47777053/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com