< prev index next >
test/compiler/compilercontrol/share/scenario/Executor.java
Print this page
rev 9430 : [mq]: PrintDirectives
rev 9429 : imported patch StressJCMD
@@ -36,18 +36,20 @@
import java.io.PrintWriter;
import java.lang.reflect.Executable;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
public class Executor {
private final boolean isValid;
private final List<String> vmOptions;
private final Map<Executable, State> states;
private final List<String> jcmdCommands;
+ private OutputAnalyzer[] jcmdOutputAnalyzers;
/**
* Constructor
*
* @param isValid shows that the input given to the VM is valid and
@@ -71,11 +73,11 @@
/**
* Executes separate VM a gets an OutputAnalyzer instance with the results
* of execution
*/
- public OutputAnalyzer execute() {
+ public List<OutputAnalyzer> execute() {
// Add class name that would be executed in a separate VM
String classCmd = BaseAction.class.getName();
vmOptions.add(classCmd);
OutputAnalyzer output;
try (ServerSocket serverSocket = new ServerSocket(0)) {
@@ -97,11 +99,17 @@
output = ProcessTools.executeTestJvmAllArgs(
vmOptions.toArray(new String[vmOptions.size()]));
} catch (Throwable thr) {
throw new Error("Execution failed: " + thr.getMessage(), thr);
}
- return output;
+
+ List<OutputAnalyzer> outputList = new ArrayList<>();
+ outputList.add(output);
+ if (jcmdOutputAnalyzers != null) {
+ Collections.addAll(outputList, jcmdOutputAnalyzers);
+ }
+ return outputList;
}
/*
* Performs connection with a test VM, sends method states and performs
* JCMD operations on a test VM.
@@ -119,11 +127,11 @@
BufferedReader in = new BufferedReader(new InputStreamReader(
socket.getInputStream()))) {
// Get pid of the executed process
int pid = Integer.parseInt(in.readLine());
Asserts.assertNE(pid, 0, "Got incorrect pid");
- executeJCMD(pid);
+ jcmdOutputAnalyzers = executeJCMD(pid);
if (states != null) {
// serialize and send state map
states.forEach((executable, state) -> {
pw.println("{");
pw.println(executable.toGenericString());
@@ -137,12 +145,15 @@
throw new Error("Failed to write data: " + e.getMessage(), e);
}
}
// Executes all diagnostic commands
- protected void executeJCMD(int pid) {
+ protected OutputAnalyzer[] executeJCMD(int pid) {
+ int size = jcmdCommands.size();
+ OutputAnalyzer[] outputArray = new OutputAnalyzer[size];
CommandExecutor jcmdExecutor = new PidJcmdExecutor(String.valueOf(pid));
- for (String command : jcmdCommands) {
- jcmdExecutor.execute(command);
+ for (int i = 0; i < size; i++) {
+ outputArray[i] = jcmdExecutor.execute(jcmdCommands.get(i));
}
+ return outputArray;
}
}
< prev index next >