List of usage examples for org.apache.hadoop.util Shell.ExitCodeException getExitCode
public int getExitCode()
From source file:ParascaleFileStatus.java
License:Apache License
void loadPermissionInfo() { if (permissionLoaded.get()) { return;/* w w w .j a v a2 s . c o m*/ } IOException e = null; try { final StringTokenizer t = new StringTokenizer(getPermissionString()); // expected format // -rw------- 1 username groupname ... String permission = t.nextToken(); if (permission.length() > 10) { permission = permission.substring(0, 10); } setPermission(FsPermission.valueOf(permission)); t.nextToken(); setOwner(t.nextToken()); setGroup(t.nextToken()); } catch (final Shell.ExitCodeException ioe) { if (ioe.getExitCode() != 1) { e = ioe; } else { setPermission(null); setOwner(null); setGroup(null); } } catch (final IOException ioe) { e = ioe; } finally { if (e != null) { throw new RuntimeException("Error while running command to get " + "file permissions : " + StringUtils.stringifyException(e)); } permissionLoaded.set(true); } }
From source file:org.apache.hive.jdbc.TestSSL.java
License:Apache License
private int execCommand(String cmd) throws Exception { int exitCode; try {/* w w w.j av a2s . co m*/ String output = Shell.execCommand("bash", "-c", cmd); LOG.info("Output from '" + cmd + "': " + output); exitCode = 0; } catch (Shell.ExitCodeException e) { exitCode = e.getExitCode(); LOG.info("Error executing '" + cmd + "', exitCode = " + exitCode, e); } return exitCode; }