本文整理汇总了Java中jdk.testlibrary.JDKToolLauncher类的典型用法代码示例。如果您正苦于以下问题:Java JDKToolLauncher类的具体用法?Java JDKToolLauncher怎么用?Java JDKToolLauncher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JDKToolLauncher类属于jdk.testlibrary包,在下文中一共展示了JDKToolLauncher类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: jcmd
import jdk.testlibrary.JDKToolLauncher; //导入依赖的package包/类
/**
* Run the "jcmd" command
* @param target The target application name (or PID)
* @param c {@linkplain Consumer} instance; may be null
* @param command Command with parameters; space separated string
* @throws IOException
* @throws InterruptedException
*/
private static void jcmd(String target, final Consumer<String> c, String ... command) throws IOException, InterruptedException {
dbg_print("[jcmd] " + (command.length > 0 ? command[0] : "list"));
JDKToolLauncher l = JDKToolLauncher.createUsingTestJDK("jcmd");
l.addToolArg(target);
for(String cmd : command) {
l.addToolArg(cmd);
}
Process p = ProcessTools.startProcess(
"jcmd",
new ProcessBuilder(l.getCommand()),
c
);
p.waitFor();
dbg_print("[jcmd] --------");
}
示例2: jps
import jdk.testlibrary.JDKToolLauncher; //导入依赖的package包/类
/**
* Start jps utility with VM args and tool arguments
*/
public static OutputAnalyzer jps(List<String> vmArgs, List<String> toolArgs) throws Exception {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jps");
if (vmArgs != null) {
for (String vmArg : vmArgs) {
launcher.addVMArg(vmArg);
}
}
if (toolArgs != null) {
for (String toolArg : toolArgs) {
launcher.addToolArg(toolArg);
}
}
ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand());
System.out.println(Arrays.toString(processBuilder.command().toArray()).replace(",", ""));
OutputAnalyzer output = new OutputAnalyzer(processBuilder.start());
System.out.println(output.getOutput());
return output;
}
示例3: runJps
import jdk.testlibrary.JDKToolLauncher; //导入依赖的package包/类
/**
* Depending on test settings command line can look like:
*
* jps -J-XX:+UsePerfData hostname
* jps -J-XX:+UsePerfData hostname:port
* jps -J-XX:+UsePerfData hostname/serverName
* jps -J-XX:+UsePerfData hostname:port/serverName
*/
private OutputAnalyzer runJps() throws Exception {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jps");
launcher.addVMArg("-XX:+UsePerfData");
// Run jps with -v flag to obtain -Dparent.pid.<pid>
launcher.addToolArg("-v");
launcher.addToolArg(getDestination());
String[] cmd = launcher.getCommand();
log("Start jps", cmd);
ProcessBuilder processBuilder = new ProcessBuilder(cmd);
OutputAnalyzer output = new OutputAnalyzer(processBuilder.start());
System.out.println(output.getOutput());
return output;
}
示例4: runJstat
import jdk.testlibrary.JDKToolLauncher; //导入依赖的package包/类
/**
* Depending on test settings command line can look like:
*
* jstat -J-XX:+UsePerfData -J-Duser.language=en -gcutil [email protected] 250 5
* jstat -J-XX:+UsePerfData -J-Duser.language=en -gcutil [email protected]:port 250 5
* jstat -J-XX:+UsePerfData -J-Duser.language=en -gcutil [email protected]/serverName 250 5
* jstat -J-XX:+UsePerfData -J-Duser.language=en -gcutil [email protected]:port/serverName 250 5
*/
private OutputAnalyzer runJstat() throws Exception {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jstat");
launcher.addVMArg("-XX:+UsePerfData");
launcher.addVMArg("-Duser.language=en");
launcher.addToolArg("-gcutil");
launcher.addToolArg(jstatdPid + "@" + getDestination());
launcher.addToolArg(Integer.toString(JSTAT_GCUTIL_INTERVAL_MS));
launcher.addToolArg(Integer.toString(JSTAT_GCUTIL_SAMPLES));
String[] cmd = launcher.getCommand();
log("Start jstat", cmd);
ProcessBuilder processBuilder = new ProcessBuilder(cmd);
OutputAnalyzer output = new OutputAnalyzer(processBuilder.start());
System.out.println(output.getOutput());
return output;
}
示例5: getJstatdCmd
import jdk.testlibrary.JDKToolLauncher; //导入依赖的package包/类
/**
* Depending on test settings command line can look like:
*
* jstatd -J-XX:+UsePerfData -J-Djava.security.policy=all.policy
* jstatd -J-XX:+UsePerfData -J-Djava.security.policy=all.policy -p port
* jstatd -J-XX:+UsePerfData -J-Djava.security.policy=all.policy -n serverName
* jstatd -J-XX:+UsePerfData -J-Djava.security.policy=all.policy -p port -n serverName
*/
private String[] getJstatdCmd() throws Exception {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jstatd");
launcher.addVMArg("-XX:+UsePerfData");
String testSrc = System.getProperty("test.src");
File policy = new File(testSrc, "all.policy");
assertTrue(policy.exists() && policy.isFile(),
"Security policy " + policy.getAbsolutePath() + " does not exist or not a file");
launcher.addVMArg("-Djava.security.policy=" + policy.getAbsolutePath());
// -Dparent.pid.<pid> will help to identify jstad process started by this test
launcher.addVMArg("-Dparent.pid." + ProcessTools.getProcessId());
if (port != null) {
launcher.addToolArg("-p");
launcher.addToolArg(port);
}
if (serverName != null) {
launcher.addToolArg("-n");
launcher.addToolArg(serverName);
}
String[] cmd = launcher.getCommand();
log("Start jstatd", cmd);
return cmd;
}
示例6: runSchemaGen
import jdk.testlibrary.JDKToolLauncher; //导入依赖的package包/类
private static void runSchemaGen(String classFile, Path runDir) {
try {
JDKToolLauncher sgl = JDKToolLauncher.createUsingTestJDK("schemagen");
sgl.addToolArg(classFile);
System.out.println("Executing: " + Arrays.asList(sgl.getCommand()));
ProcessBuilder pb = new ProcessBuilder(sgl.getCommand());
pb.directory(runDir.toFile());
pb.redirectErrorStream(true);
pb.inheritIO();
Process p = pb.start();
int result = p.waitFor();
p.destroy();
if (result != 0) {
throw new RuntimeException("schemagen failed");
}
} catch (IOException | InterruptedException e) {
System.err.println("Can't run schemagen tool. Exception:");
e.printStackTrace(System.err);
throw new RuntimeException("Error launching schemagen tool");
}
}
示例7: jps
import jdk.testlibrary.JDKToolLauncher; //导入依赖的package包/类
/**
* Start jps utility with VM args and tool arguments
*/
public static OutputAnalyzer jps(List<String> vmArgs, List<String> toolArgs) throws Exception {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jps");
launcher.addVMArg("-XX:+UsePerfData");
if (vmArgs != null) {
for (String vmArg : vmArgs) {
launcher.addVMArg(vmArg);
}
}
if (toolArgs != null) {
for (String toolArg : toolArgs) {
launcher.addToolArg(toolArg);
}
}
ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand());
System.out.println(Arrays.toString(processBuilder.command().toArray()).replace(",", ""));
OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
System.out.println(output.getOutput());
return output;
}
示例8: jmap
import jdk.testlibrary.JDKToolLauncher; //导入依赖的package包/类
private static OutputAnalyzer jmap(String... toolArgs) throws Exception {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jmap");
if (toolArgs != null) {
for (String toolArg : toolArgs) {
launcher.addToolArg(toolArg);
}
}
launcher.addToolArg(Long.toString(ProcessTools.getProcessId()));
processBuilder.command(launcher.getCommand());
System.out.println(Arrays.toString(processBuilder.command().toArray()).replace(",", ""));
OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
System.out.println(output.getOutput());
return output;
}
示例9: jstack
import jdk.testlibrary.JDKToolLauncher; //导入依赖的package包/类
private static OutputAnalyzer jstack(String... toolArgs) throws Exception {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jstack");
launcher.addVMArg("-XX:+UsePerfData");
if (toolArgs != null) {
for (String toolArg : toolArgs) {
launcher.addToolArg(toolArg);
}
}
processBuilder.command(launcher.getCommand());
System.out.println(processBuilder.command().stream().collect(Collectors.joining(" ")));
OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
System.out.println(output.getOutput());
return output;
}
示例10: jstack
import jdk.testlibrary.JDKToolLauncher; //导入依赖的package包/类
private static OutputAnalyzer jstack(String... toolArgs) throws Exception {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jstack");
launcher.addVMArg("-XX:+UsePerfData");
if (toolArgs != null) {
for (String toolArg : toolArgs) {
launcher.addToolArg(toolArg);
}
}
launcher.addToolArg(Long.toString(ProcessTools.getProcessId()));
processBuilder.command(launcher.getCommand());
System.out.println(Arrays.toString(processBuilder.command().toArray()).replace(",", ""));
OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
System.out.println(output.getOutput());
return output;
}
示例11: jinfo
import jdk.testlibrary.JDKToolLauncher; //导入依赖的package包/类
private static OutputAnalyzer jinfo(String... toolArgs) throws Exception {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jinfo");
if (toolArgs != null) {
for (String toolArg : toolArgs) {
launcher.addToolArg(toolArg);
}
}
launcher.addToolArg(Long.toString(ProcessTools.getProcessId()));
processBuilder.command(launcher.getCommand());
System.out.println(Arrays.toString(processBuilder.command().toArray()).replace(",", ""));
OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
System.out.println(output.getOutput());
return output;
}
示例12: runJstat
import jdk.testlibrary.JDKToolLauncher; //导入依赖的package包/类
/**
* Depending on test settings command line can look like:
*
* jstat -J-XX:+UsePerfData -J-Duser.language=en -gcutil [email protected] 250 5
* jstat -J-XX:+UsePerfData -J-Duser.language=en -gcutil [email protected]:port 250 5
* jstat -J-XX:+UsePerfData -J-Duser.language=en -gcutil [email protected]/serverName 250 5
* jstat -J-XX:+UsePerfData -J-Duser.language=en -gcutil [email protected]:port/serverName 250 5
*/
private OutputAnalyzer runJstat() throws Exception {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jstat");
launcher.addVMArg("-XX:+UsePerfData");
launcher.addVMArg("-Duser.language=en");
launcher.addToolArg("-gcutil");
launcher.addToolArg(jstatdPid + "@" + getDestination());
launcher.addToolArg(Integer.toString(JSTAT_GCUTIL_INTERVAL_MS));
launcher.addToolArg(Integer.toString(JSTAT_GCUTIL_SAMPLES));
String[] cmd = launcher.getCommand();
log("Start jstat", cmd);
ProcessBuilder processBuilder = new ProcessBuilder(cmd);
OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
System.out.println(output.getOutput());
return output;
}
示例13: getJstatdCmd
import jdk.testlibrary.JDKToolLauncher; //导入依赖的package包/类
/**
* Depending on test settings command line can look like:
*
* jstatd -J-XX:+UsePerfData -J-Djava.security.policy=all.policy
* jstatd -J-XX:+UsePerfData -J-Djava.security.policy=all.policy -p port
* jstatd -J-XX:+UsePerfData -J-Djava.security.policy=all.policy -n serverName
* jstatd -J-XX:+UsePerfData -J-Djava.security.policy=all.policy -p port -n serverName
*/
private String[] getJstatdCmd() throws Exception {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jstatd");
launcher.addVMArg("-XX:+UsePerfData");
String testSrc = System.getProperty("test.src");
File policy = new File(testSrc, "all.policy");
assertTrue(policy.exists() && policy.isFile(),
"Security policy " + policy.getAbsolutePath() + " does not exist or not a file");
launcher.addVMArg("-Djava.security.policy=" + policy.getAbsolutePath());
if (port != null) {
launcher.addToolArg("-p");
launcher.addToolArg(port);
}
if (serverName != null) {
launcher.addToolArg("-n");
launcher.addToolArg(serverName);
}
if (withExternalRegistry) {
launcher.addToolArg("-nr");
}
String[] cmd = launcher.getCommand();
log("Start jstatd", cmd);
return cmd;
}