YARN-3344. Fix warning - procfs stat file is not in the expected format. (Ravindra Kumar Naik and Akira Ajisaka via kasha)
(cherry picked from commit 77d5ce9069
)
This commit is contained in:
parent
71e5b36763
commit
0ac8c098e8
|
@ -58,9 +58,9 @@ public class ProcfsBasedProcessTree extends ResourceCalculatorProcessTree {
|
||||||
private static final String PROCFS = "/proc/";
|
private static final String PROCFS = "/proc/";
|
||||||
|
|
||||||
private static final Pattern PROCFS_STAT_FILE_FORMAT = Pattern.compile(
|
private static final Pattern PROCFS_STAT_FILE_FORMAT = Pattern.compile(
|
||||||
"^([0-9-]+)\\s([^\\s]+)\\s[^\\s]\\s([0-9-]+)\\s([0-9-]+)\\s([0-9-]+)\\s" +
|
"^([\\d-]+)\\s\\(([^)]+)\\)\\s[^\\s]\\s([\\d-]+)\\s([\\d-]+)\\s" +
|
||||||
"([0-9-]+\\s){7}([0-9]+)\\s([0-9]+)\\s([0-9-]+\\s){7}([0-9]+)\\s([0-9]+)" +
|
"([\\d-]+)\\s([\\d-]+\\s){7}(\\d+)\\s(\\d+)\\s([\\d-]+\\s){7}(\\d+)\\s" +
|
||||||
"(\\s[0-9-]+){15}");
|
"(\\d+)(\\s[\\d-]+){15}");
|
||||||
|
|
||||||
public static final String PROCFS_STAT_FILE = "stat";
|
public static final String PROCFS_STAT_FILE = "stat";
|
||||||
public static final String PROCFS_CMDLINE_FILE = "cmdline";
|
public static final String PROCFS_CMDLINE_FILE = "cmdline";
|
||||||
|
@ -537,8 +537,9 @@ public class ProcfsBasedProcessTree extends ResourceCalculatorProcessTree {
|
||||||
Matcher m = PROCFS_STAT_FILE_FORMAT.matcher(str);
|
Matcher m = PROCFS_STAT_FILE_FORMAT.matcher(str);
|
||||||
boolean mat = m.find();
|
boolean mat = m.find();
|
||||||
if (mat) {
|
if (mat) {
|
||||||
|
String processName = "(" + m.group(2) + ")";
|
||||||
// Set (name) (ppid) (pgrpId) (session) (utime) (stime) (vsize) (rss)
|
// Set (name) (ppid) (pgrpId) (session) (utime) (stime) (vsize) (rss)
|
||||||
pinfo.updateProcessInfo(m.group(2), m.group(3),
|
pinfo.updateProcessInfo(processName, m.group(3),
|
||||||
Integer.parseInt(m.group(4)), Integer.parseInt(m.group(5)),
|
Integer.parseInt(m.group(4)), Integer.parseInt(m.group(5)),
|
||||||
Long.parseLong(m.group(7)), new BigInteger(m.group(8)),
|
Long.parseLong(m.group(7)), new BigInteger(m.group(8)),
|
||||||
Long.parseLong(m.group(10)), Long.parseLong(m.group(11)));
|
Long.parseLong(m.group(10)), Long.parseLong(m.group(11)));
|
||||||
|
|
|
@ -417,7 +417,7 @@ public class TestProcfsBasedProcessTree {
|
||||||
new ProcessStatInfo(new String[]{"100", "proc1", "1", "100", "100",
|
new ProcessStatInfo(new String[]{"100", "proc1", "1", "100", "100",
|
||||||
"100000", "100", "1000", "200"});
|
"100000", "100", "1000", "200"});
|
||||||
procInfos[1] =
|
procInfos[1] =
|
||||||
new ProcessStatInfo(new String[] { "200", "proc2", "100", "100",
|
new ProcessStatInfo(new String[]{"200", "process two", "100", "100",
|
||||||
"100", "200000", "200", "2000", "400"});
|
"100", "200000", "200", "2000", "400"});
|
||||||
procInfos[2] =
|
procInfos[2] =
|
||||||
new ProcessStatInfo(new String[]{"300", "proc3", "200", "100",
|
new ProcessStatInfo(new String[]{"300", "proc3", "200", "100",
|
||||||
|
@ -484,7 +484,7 @@ public class TestProcfsBasedProcessTree {
|
||||||
new ProcessStatInfo(new String[]{"100", "proc1", "1", "100", "100",
|
new ProcessStatInfo(new String[]{"100", "proc1", "1", "100", "100",
|
||||||
"100000", "100", "2000", "300"});
|
"100000", "100", "2000", "300"});
|
||||||
procInfos[1] =
|
procInfos[1] =
|
||||||
new ProcessStatInfo(new String[] { "200", "proc2", "100", "100",
|
new ProcessStatInfo(new String[]{"200", "process two", "100", "100",
|
||||||
"100", "200000", "200", "3000", "500"});
|
"100", "200000", "200", "3000", "500"});
|
||||||
writeStatFiles(procfsRootDir, pids, procInfos, memInfo);
|
writeStatFiles(procfsRootDir, pids, procInfos, memInfo);
|
||||||
|
|
||||||
|
@ -561,7 +561,7 @@ public class TestProcfsBasedProcessTree {
|
||||||
new ProcessStatInfo(new String[]{"100", "proc1", "1", "100", "100",
|
new ProcessStatInfo(new String[]{"100", "proc1", "1", "100", "100",
|
||||||
"100000", "100"});
|
"100000", "100"});
|
||||||
procInfos[1] =
|
procInfos[1] =
|
||||||
new ProcessStatInfo(new String[] { "200", "proc2", "100", "100",
|
new ProcessStatInfo(new String[]{"200", "process two", "100", "100",
|
||||||
"100", "200000", "200"});
|
"100", "200000", "200"});
|
||||||
procInfos[2] =
|
procInfos[2] =
|
||||||
new ProcessStatInfo(new String[]{"300", "proc3", "1", "300", "300",
|
new ProcessStatInfo(new String[]{"300", "proc3", "1", "300", "300",
|
||||||
|
@ -807,7 +807,7 @@ public class TestProcfsBasedProcessTree {
|
||||||
new ProcessStatInfo(new String[]{"100", "proc1", "1", "100", "100",
|
new ProcessStatInfo(new String[]{"100", "proc1", "1", "100", "100",
|
||||||
"100000", "100", "1000", "200"});
|
"100000", "100", "1000", "200"});
|
||||||
procInfos[1] =
|
procInfos[1] =
|
||||||
new ProcessStatInfo(new String[] { "200", "proc2", "100", "100",
|
new ProcessStatInfo(new String[]{"200", "process two", "100", "100",
|
||||||
"100", "200000", "200", "2000", "400"});
|
"100", "200000", "200", "2000", "400"});
|
||||||
procInfos[2] =
|
procInfos[2] =
|
||||||
new ProcessStatInfo(new String[]{"300", "proc3", "200", "100",
|
new ProcessStatInfo(new String[]{"300", "proc3", "200", "100",
|
||||||
|
@ -832,7 +832,7 @@ public class TestProcfsBasedProcessTree {
|
||||||
|
|
||||||
String[] cmdLines = new String[numProcesses];
|
String[] cmdLines = new String[numProcesses];
|
||||||
cmdLines[0] = "proc1 arg1 arg2";
|
cmdLines[0] = "proc1 arg1 arg2";
|
||||||
cmdLines[1] = "proc2 arg3 arg4";
|
cmdLines[1] = "process two arg3 arg4";
|
||||||
cmdLines[2] = "proc3 arg5 arg6";
|
cmdLines[2] = "proc3 arg5 arg6";
|
||||||
cmdLines[3] = "proc4 arg7 arg8";
|
cmdLines[3] = "proc4 arg7 arg8";
|
||||||
cmdLines[4] = "proc5 arg9 arg10";
|
cmdLines[4] = "proc5 arg9 arg10";
|
||||||
|
|
Loading…
Reference in New Issue