DefaultProcReader implements ProcReader { @Override public Map<String, ProcStatus> listTaskStatus(String pid) throws IOException { File taskDir = new File(String.format("%s/%s/task", procBasePath, pid)); Map<String, ProcStatus> procStatusMap = Maps.newHashMap(); for (File pidDir : taskDir.listFiles()) { File statusFile = new File(pidDir, STATUS); List<String> lines = Files.readLines(statusFile, Charset.defaultCharset()); String statusStr = lines.get(1); procStatusMap.put(pidDir.getName(), ProcStatus.convertStatus(statusStr)); } return procStatusMap; }  @Override List<File> listContainerCgroupFiles(); @Override List<String> listProcesses(File cgroupFile); @Override Map<String, ProcStatus> listTaskStatus(String pid); static final String CGROUP_PROCS; static final String STATUS; }
@Test public void testListTaskStatus() throws Exception { Map<String, ProcStatus> procStatusMap = procReader.listTaskStatus("1001"); Assert.assertEquals(procStatusMap.get("1001001"), ProcStatus.RUNNING); Assert.assertEquals(procStatusMap.get("1001002"), ProcStatus.SLEEPING); procStatusMap = procReader.listTaskStatus("1002"); Assert.assertEquals(procStatusMap.get("1002001"), ProcStatus.RUNNING); Assert.assertEquals(procStatusMap.get("1002002"), ProcStatus.ZOMBIE); }