final MessageConsole console = new MessageConsole("Hadoop: " + command,
null);
final MessageConsoleStream stream = console.newMessageStream();
final IOConsoleOutputStream out = console.newOutputStream();
final IOConsoleOutputStream err = console.newOutputStream();
out.setColor(black);
err.setColor(red);
ConsolePlugin.getDefault().getConsoleManager().addConsoles(
new IConsole[] { console });
ConsolePlugin.getDefault().getConsoleManager().showConsoleView(console);
channel.setCommand(command);
channel.setInputStream(null);
channel.connect();
new Thread() {
@Override
public void run() {
try {
BufferedReader hadoopOutput = new BufferedReader(
new InputStreamReader(channel.getInputStream()));
String stdoutLine;
while ((stdoutLine = hadoopOutput.readLine()) != null) {
out.write(stdoutLine);
out.write('\n');
continue;
}
channel.disconnect();
// meaningless call meant to prevent console from being
// garbage collected -- eyhung
console.getName();
ChannelExec channel2 = (ChannelExec) session.openChannel("exec");
channel2.setCommand("rm -rf "
+ jarFile.substring(0, jarFile.lastIndexOf("/")));
log.fine("Removing temp file "
+ jarFile.substring(0, jarFile.lastIndexOf("/")));
channel2.connect();
channel2.disconnect();
} catch (Exception e) {
}
}
}.start();
new Thread() {
@Override
public void run() {
try {
BufferedReader hadoopErr = new BufferedReader(new InputStreamReader(
channel.getErrStream()));
// String stdoutLine;
String stderrLine;
while ((stderrLine = hadoopErr.readLine()) != null) {
err.write(stderrLine);
err.write('\n');
continue;
}
} catch (Exception e) {
}