2017-12-12 21 views
0

私はJavaでMR2ジョブを持っています。 コンテナ内のコンテナキルを検出して処理することは可能ですか? 私はYARNがコンテナを殺すと検出する

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

ようなコードを使用しようとしたが、フッカークラスのインスタンスからのログは見つからなかったがありました。 このコンテナの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) 

おかげ

答えて

0

です。

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(); 
     } 
    } 
} 

}

+0

私は、ジョブが失敗した後、マッパー内のイベントを検出する必要はないわけ。 – realfreeman

関連する問題