use of org.apache.zookeeper.Shell.ExitCodeException in project SilverKing by Morgan-Stanley.
the class Ping method ping.
public Pair<Boolean, String> ping(String dest, int count) throws IOException {
ProcessExecutor pe;
String[] cmd;
boolean ok;
String output;
cmd = new String[4];
cmd[0] = ping;
cmd[1] = "-c";
cmd[2] = Integer.toString(count);
cmd[3] = dest;
pe = new ProcessExecutor(cmd);
try {
pe.execute();
ok = pe.getExitCode() == 0;
output = pe.getOutput();
} catch (ExitCodeException ece) {
ok = false;
output = null;
}
return new Pair<>(ok, output);
}
Aggregations