in modules/ssh-ext/src/main/java/org/apache/ignite/internal/util/nodestart/StartNodeCallableImpl.java [477:531]
private String exec(Session ses, final String cmd, String encoding) throws JSchException, IOException {
ChannelExec ch = null;
try {
ch = (ChannelExec)ses.openChannel("exec");
ch.setCommand(cmd);
ch.connect();
if (encoding == null)
encoding = Charset.defaultCharset().name();
GridTimeoutObject to = null;
SB out = null;
try (BufferedReader reader = new BufferedReader(new InputStreamReader(ch.getInputStream(), encoding))) {
String line;
boolean first = true;
while ((line = reader.readLine()) != null) {
if (first)
out = new SB();
else
out.a('\n');
out.a(line);
if (first) {
to = initTimer(cmd);
first = false;
}
}
}
catch (InterruptedIOException ignore) {
// No-op.
}
finally {
if (to != null) {
boolean r = proc.removeTimeoutObject(to);
assert r || to.endTime() <= U.currentTimeMillis() : "Timeout object was not removed: " + to;
}
}
return out == null ? null : out.toString();
}
finally {
if (ch != null && ch.isConnected())
ch.disconnect();
}
}