8218197: [failurehandler] parent processes shouldn't be killed till their children are handle

Reviewed-by: dholmes, kbarrett
This commit is contained in:
Igor Ignatyev 2019-02-04 17:53:26 -08:00
parent 103b6b2d69
commit ac1b5fb59a
4 changed files with 27 additions and 21 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -153,13 +153,11 @@ public class HtmlSection {
public HtmlSection createChildren(String[] sections) {
int i = 0;
int n = sections.length;
HtmlSection current = rootSection;
if (current != null) {
for (; i < n && current.child != null;
++i, current = current.child) {
if (!sections[i].equals(current.child.name)) {
break;
}
HtmlSection current = this;
for (; i < n && current.child != null;
++i, current = current.child) {
if (!sections[i].equals(current.child.name)) {
break;
}
}
for (; i < n; ++i) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -31,6 +31,7 @@ import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Deque;
public class ToolKit implements EnvironmentInfoGatherer, ProcessInfoGatherer {
private final List<ActionSet> actions = new ArrayList<>();
@ -52,20 +53,27 @@ public class ToolKit implements EnvironmentInfoGatherer, ProcessInfoGatherer {
@Override
public void gatherProcessInfo(HtmlSection section, long pid) {
Queue<Long> pids = new LinkedList<>();
pids.add(pid);
for (Long p = pids.poll(); p != null; p = pids.poll()) {
HtmlSection pidSection = section.createChildren("" + p);
List<Long> children = helper.getChildren(pidSection, p);
// as some of actions can kill a process, we need to get children of all
// test process first, and run the actions starting from the leaves
// and going up by the process tree
Deque<Long> orderedPids = new LinkedList<>();
Queue<Long> testPids = new LinkedList<>();
testPids.add(pid);
HtmlSection ptreeSection = section.createChildren("test_processes");
for (Long p = testPids.poll(); p != null; p = testPids.poll()) {
orderedPids.addFirst(p);
List<Long> children = helper.getChildren(ptreeSection, p);
if (!children.isEmpty()) {
HtmlSection s = pidSection.createChildren("children");
HtmlSection s = ptreeSection.createChildren("" + p);
for (Long c : children) {
s.link(section, c.toString(), c.toString());
}
pids.addAll(children);
testPids.addAll(children);
}
}
for (Long p : orderedPids) {
for (ActionSet set : actions) {
set.gatherProcessInfo(pidSection, p);
set.gatherProcessInfo(section, p);
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -64,7 +64,7 @@ public class ActionHelper {
public ActionHelper(Path workDir, String prefix, Properties properties,
Path... jdks) throws InvalidValueException {
this.workDir = workDir.toAbsolutePath();
getChildren = new PatternAction("children",
getChildren = new PatternAction(null,
Utils.prependPrefix(prefix, "getChildren"), properties);
ValueHandler.apply(this, properties, prefix);
String[] pathStrings = System.getenv("PATH").split(File.pathSeparator);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -44,7 +44,7 @@ public class PatternAction implements Action {
public PatternAction(String name, String id, Properties properties)
throws InvalidValueException {
action = new SimpleAction(("pattern." + name), id, properties);
action = new SimpleAction(name != null ? ("pattern." + name) : "pattern", id, properties);
ValueHandler.apply(this, properties, id);
originalArgs = action.args.clone();
}