if ( agent != null ) {
// check if this process is in any of the cgroups. If so, this process is not rogue
if ( ((NodeAgent)agent).useCgroups && ((NodeAgent)agent).cgroupsManager.isPidInCGroup(pid) ) {
continue; // not rogue, this process is in a cgroup
}
NodeUsersInfo nui = null;
// Check if user record is already in the map. May have been done above in
// copyAllUserReservations().
if ( map.containsKey(user)) {
nui = map.get(user);
} else {
nui = new NodeUsersInfo(user);
map.put(user, nui);
}
if ( logger == null ) {
// System.out.println(
// "User:"+user+" Reservations:"+nui.getReservations().size()+" Rogue Processes:"+nui.getRogueProcesses().size());
} else {
logger.info(location, null, "User:"+user+" Reservations:"+nui.getReservations().size()+" Rogue Processes:"+nui.getRogueProcesses().size());
}
// add a process to a list of processes currently running on the node. The list will be used
// to remove stale rogue processes at the end of this method
// currentPids.add(tokens[1]);
currentPids.add(pid);
if ( logger == null ) {
} else {
logger.trace(location, null,"Current Process (Before Calling aggregate() - PID:"+pid+" PPID:"+ppid+" Process List Size:"+processList.size());
}
NodeUsersCollector.ProcessInfo pi =
new NodeUsersCollector.ProcessInfo(Integer.parseInt(pid),Integer.parseInt(ppid));
// add the process to the list of processes. If this process has a parent, it will be added as a child. Compose
// hierarchy of processes so that we can use it later to determine if any given process has a parent that is rogue
aggregate(processList, pi);
// fetch user reservations
List<IDuccId> userReservations = nui.getReservations();
// if user has reservations on the node, any process found is not a rogue process
if ( userReservations.size() > 0 ) {
boolean found = false;
// check if this process has previously been marked as rogue
for( NodeProcess rogue : nui.getRogueProcesses() ) {
if ( rogue.getPid().equals(pid)) {
found = true;
break;
}
}
if ( !found && !agent.isManagedProcess(processList, pi)) {
// code keeps count of java and non-java processes separately, so pass the type of process (java or not)
// to allow distinct accounting
nui.addPid(pid, ppid, cmd.endsWith("java"));
}
continue; // all we know that the user has a reservation and there is a process running. If there
// are reservations, we cant determine which user process is a rogue process
}
// detect if this is a rogue process and add it to the rogue process list. First check if the current process
// has a parent and if so, check if the parent is rogue. Second, if parent is not rogue (or no parent)
// check if the process is in agent's inventory. If its not, we have a rogue process.
if ( agent.isRogueProcess(user, processList, pi) ) {
if ( nui.getRogueProcesses().size() == 0 || !inRogueList(nui.getRogueProcesses(),pid) ) {
pi.setRogue(true);
// agent.getRogueProcessReaper().submitRogueProcessForKill(user, pid, ppid, cmd.endsWith("java"));
}
agent.getRogueProcessReaper().submitRogueProcessForKill(user, pid, ppid, cmd.endsWith("java"));
}