java Runtime exec
来源:互联网 发布:学php好就业吗 编辑:程序博客网 时间:2024/05/16 11:27
Processor executor = Runtime.getRuntime().exec(cmdLine, env, new File(workDir));
StreamPrinter outPrinter = new StreamPrinter(
executor.getInputStream(), null,
SessionState.getConsole().getChildOutStream());
StreamPrinter errPrinter = new StreamPrinter(
executor.getErrorStream(), null,
SessionState.getConsole().getChildErrStream());
outPrinter.start();
errPrinter.start();
int exitVal = jobExecHelper.progressLocal(executor, getId());
public static class StreamPrinter extends Thread {
InputStream is;
String type;
PrintStream os;
public StreamPrinter(InputStream is, String type, PrintStream os) {
this.is = is;
this.type = type;
this.os = os;
}
@Override
public void run() {
BufferedReader br = null;
try {
InputStreamReader isr = new InputStreamReader(is);
br = new BufferedReader(isr);
String line = null;
if (type != null) {
while ((line = br.readLine()) != null) {
os.println(type + ">" + line);
}
} else {
while ((line = br.readLine()) != null) {
os.println(line);
}
}
br.close();
br=null;
} catch (IOException ioe) {
ioe.printStackTrace();
}finally{
IOUtils.closeStream(br);
}
}
}
public int progressLocal(Process runningJob, String taskId) {
int exitVal = -101;
try {
exitVal = runningJob.waitFor(); //TODO: poll periodically
} catch (InterruptedException e) {
}
if (exitVal != 0) {
console.printError("Execution failed with exit status: " + exitVal);
console.printError("Obtaining error information");
if (HiveConf.getBoolVar(job, HiveConf.ConfVars.SHOW_JOB_FAIL_DEBUG_INFO)) {
// Since local jobs are run sequentially, all relevant information is already available
// Therefore, no need to fetch job debug info asynchronously
localJobDebugger(exitVal, taskId);
}
} else {
console.printInfo("Execution completed successfully");
console.printInfo("Mapred Local Task Succeeded . Convert the Join into MapJoin");
}
return exitVal;
}
- java Runtime.getRuntime().exec
- Java Runtime.exec()注意事项
- Java Runtime.exec()注意事项
- java runtime.exec()
- java Runtime.getRuntime().exec()
- java Runtime exec
- Java Runtime.exec() hangs
- Java Runtime.exec() 使用
- Java Runtime.exec()注意事项
- Java Runtime.exec()注意事项
- Java Runtime.exec()注意事项
- 关于java runtime.exec()
- java runtime.exec常见问题
- java runtime.exec() 的编写
- java runtime.exec() 的编写
- java runtime.exec() 的编写
- Java Runtime.getRuntime().exec()详解
- Java执行Runtime.getRuntime().exec()
- 基础备忘之c++内存分布:代码段、全局数据区、栈、堆
- 学之者生,用之者死——ACE历史与简评
- Iptables之conntrack连接跟踪模块
- 主键生成机制
- 未整理内容
- java Runtime exec
- DirectX做2D游戏的三种方法
- 如何使用Box2D和Cocos2D制作一款像Fruit Ninja一样的游戏-第2部分
- unix下取得加密的用户密码
- Android进阶练习-让你的App可定位
- 如何使用Box2D和Cocos2D制作一款像Fruit Ninja一样的游戏-第3部分
- Spring 2.5 配置注解式事务
- python mysql 乱码问题总结
- java JSTL 核心标签库使用