< prev index next >
test/compiler/compilercontrol/share/scenario/Executor.java
Print this page
rev 9430 : [mq]: PrintDirectives
rev 9429 : imported patch StressJCMD
*** 36,53 ****
--- 36,55 ----
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,81 ****
/**
* Executes separate VM a gets an OutputAnalyzer instance with the results
* of execution
*/
! public 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)) {
--- 73,83 ----
/**
* Executes separate VM a gets an OutputAnalyzer instance with the results
* of execution
*/
! 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,107 ****
output = ProcessTools.executeTestJvmAllArgs(
vmOptions.toArray(new String[vmOptions.size()]));
} catch (Throwable thr) {
throw new Error("Execution failed: " + thr.getMessage(), thr);
}
! return output;
}
/*
* Performs connection with a test VM, sends method states and performs
* JCMD operations on a test VM.
--- 99,115 ----
output = ProcessTools.executeTestJvmAllArgs(
vmOptions.toArray(new String[vmOptions.size()]));
} catch (Throwable thr) {
throw new Error("Execution failed: " + thr.getMessage(), thr);
}
!
! 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,129 ****
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);
if (states != null) {
// serialize and send state map
states.forEach((executable, state) -> {
pw.println("{");
pw.println(executable.toGenericString());
--- 127,137 ----
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");
! jcmdOutputAnalyzers = executeJCMD(pid);
if (states != null) {
// serialize and send state map
states.forEach((executable, state) -> {
pw.println("{");
pw.println(executable.toGenericString());
*** 137,148 ****
throw new Error("Failed to write data: " + e.getMessage(), e);
}
}
// Executes all diagnostic commands
! protected void executeJCMD(int pid) {
CommandExecutor jcmdExecutor = new PidJcmdExecutor(String.valueOf(pid));
! for (String command : jcmdCommands) {
! jcmdExecutor.execute(command);
}
}
}
--- 145,159 ----
throw new Error("Failed to write data: " + e.getMessage(), e);
}
}
// Executes all diagnostic commands
! protected OutputAnalyzer[] executeJCMD(int pid) {
! int size = jcmdCommands.size();
! OutputAnalyzer[] outputArray = new OutputAnalyzer[size];
CommandExecutor jcmdExecutor = new PidJcmdExecutor(String.valueOf(pid));
! for (int i = 0; i < size; i++) {
! outputArray[i] = jcmdExecutor.execute(jcmdCommands.get(i));
}
+ return outputArray;
}
}
< prev index next >