本文整理汇总了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] --------");
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:26,代码来源:JMXStartStopTest.java
示例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;
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:JpsHelper.java
示例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;
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:JstatdTest.java
示例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;
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:JstatdTest.java
示例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;
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:32,代码来源:JstatdTest.java
示例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");
}
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:GenerateEnumSchema.java
示例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;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:JpsHelper.java
示例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;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:BasicJMapTest.java
示例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;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:DeadlockDetectionTest.java
示例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;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:BasicJStackTest.java
示例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;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:BasicJInfoTest.java
示例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;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:JstatdTest.java
示例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;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:JstatdTest.java
注:本文中的jdk.testlibrary.JDKToolLauncher类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论