HADOOP-12478. Shell.getWinUtilsPath() has been renamed Shell.getWinutilsPath(). (stevel)
This commit is contained in:
parent
526be695c0
commit
0e4fb329ed
|
@ -637,6 +637,9 @@ Release 2.8.0 - UNRELEASED
|
||||||
HADOOP-11515. Upgrade jsch lib to jsch-0.1.51 to avoid problems running
|
HADOOP-11515. Upgrade jsch lib to jsch-0.1.51 to avoid problems running
|
||||||
on java7. (stevel and ozawa)
|
on java7. (stevel and ozawa)
|
||||||
|
|
||||||
|
HADOOP-12478. Shell.getWinUtilsPath() has been renamed
|
||||||
|
Shell.getWinutilsPath(). (stevel)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HADOOP-12051. ProtobufRpcEngine.invoke() should use Exception.toString()
|
HADOOP-12051. ProtobufRpcEngine.invoke() should use Exception.toString()
|
||||||
|
|
|
@ -137,7 +137,7 @@ public class HardLink {
|
||||||
@Override
|
@Override
|
||||||
String[] linkCount(File file) throws IOException {
|
String[] linkCount(File file) throws IOException {
|
||||||
// trigger the check for winutils
|
// trigger the check for winutils
|
||||||
Shell.getWinutilsFile();
|
Shell.getWinUtilsFile();
|
||||||
String[] buf = new String[getLinkCountCommand.length];
|
String[] buf = new String[getLinkCountCommand.length];
|
||||||
System.arraycopy(getLinkCountCommand, 0, buf, 0,
|
System.arraycopy(getLinkCountCommand, 0, buf, 0,
|
||||||
getLinkCountCommand.length);
|
getLinkCountCommand.length);
|
||||||
|
|
|
@ -108,7 +108,7 @@ public class NativeLibraryChecker {
|
||||||
if (Shell.WINDOWS) {
|
if (Shell.WINDOWS) {
|
||||||
// winutils.exe is required on Windows
|
// winutils.exe is required on Windows
|
||||||
try {
|
try {
|
||||||
winutilsPath = Shell.getWinutilsFile().getCanonicalPath();
|
winutilsPath = Shell.getWinUtilsFile().getCanonicalPath();
|
||||||
winutilsExists = true;
|
winutilsExists = true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.debug("No Winutils: ", e);
|
LOG.debug("No Winutils: ", e);
|
||||||
|
|
|
@ -185,7 +185,7 @@ public abstract class Shell {
|
||||||
//'groups username' command return is inconsistent across different unixes
|
//'groups username' command return is inconsistent across different unixes
|
||||||
return WINDOWS ?
|
return WINDOWS ?
|
||||||
new String[]
|
new String[]
|
||||||
{ getWinutilsPath(), "groups", "-F", "\"" + user + "\"" }
|
{ getWinUtilsPath(), "groups", "-F", "\"" + user + "\"" }
|
||||||
: new String [] {"bash", "-c", "id -gn " + user + "&& id -Gn " + user};
|
: new String [] {"bash", "-c", "id -gn " + user + "&& id -Gn " + user};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ public abstract class Shell {
|
||||||
|
|
||||||
/** Return a command to get permission information. */
|
/** Return a command to get permission information. */
|
||||||
public static String[] getGetPermissionCommand() {
|
public static String[] getGetPermissionCommand() {
|
||||||
return (WINDOWS) ? new String[] { getWinutilsPath(), "ls", "-F" }
|
return (WINDOWS) ? new String[] { getWinUtilsPath(), "ls", "-F" }
|
||||||
: new String[] { "/bin/ls", "-ld" };
|
: new String[] { "/bin/ls", "-ld" };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,11 +206,11 @@ public abstract class Shell {
|
||||||
public static String[] getSetPermissionCommand(String perm, boolean recursive) {
|
public static String[] getSetPermissionCommand(String perm, boolean recursive) {
|
||||||
if (recursive) {
|
if (recursive) {
|
||||||
return (WINDOWS) ?
|
return (WINDOWS) ?
|
||||||
new String[] { getWinutilsPath(), "chmod", "-R", perm }
|
new String[] { getWinUtilsPath(), "chmod", "-R", perm }
|
||||||
: new String[] { "chmod", "-R", perm };
|
: new String[] { "chmod", "-R", perm };
|
||||||
} else {
|
} else {
|
||||||
return (WINDOWS) ?
|
return (WINDOWS) ?
|
||||||
new String[] { getWinutilsPath(), "chmod", perm }
|
new String[] { getWinUtilsPath(), "chmod", perm }
|
||||||
: new String[] { "chmod", perm };
|
: new String[] { "chmod", perm };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,21 +234,21 @@ public abstract class Shell {
|
||||||
/** Return a command to set owner. */
|
/** Return a command to set owner. */
|
||||||
public static String[] getSetOwnerCommand(String owner) {
|
public static String[] getSetOwnerCommand(String owner) {
|
||||||
return (WINDOWS) ?
|
return (WINDOWS) ?
|
||||||
new String[] { getWinutilsPath(), "chown", "\"" + owner + "\"" }
|
new String[] { getWinUtilsPath(), "chown", "\"" + owner + "\"" }
|
||||||
: new String[] { "chown", owner };
|
: new String[] { "chown", owner };
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return a command to create symbolic links. */
|
/** Return a command to create symbolic links. */
|
||||||
public static String[] getSymlinkCommand(String target, String link) {
|
public static String[] getSymlinkCommand(String target, String link) {
|
||||||
return WINDOWS ?
|
return WINDOWS ?
|
||||||
new String[] { getWinutilsPath(), "symlink", link, target }
|
new String[] { getWinUtilsPath(), "symlink", link, target }
|
||||||
: new String[] { "ln", "-s", target, link };
|
: new String[] { "ln", "-s", target, link };
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return a command to read the target of the a symbolic link. */
|
/** Return a command to read the target of the a symbolic link. */
|
||||||
public static String[] getReadlinkCommand(String link) {
|
public static String[] getReadlinkCommand(String link) {
|
||||||
return WINDOWS ?
|
return WINDOWS ?
|
||||||
new String[] { getWinutilsPath(), "readlink", link }
|
new String[] { getWinUtilsPath(), "readlink", link }
|
||||||
: new String[] { "readlink", link };
|
: new String[] { "readlink", link };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,9 +266,9 @@ public abstract class Shell {
|
||||||
// Code == 0 means check alive
|
// Code == 0 means check alive
|
||||||
if (Shell.WINDOWS) {
|
if (Shell.WINDOWS) {
|
||||||
if (0 == code) {
|
if (0 == code) {
|
||||||
return new String[] {Shell.getWinutilsPath(), "task", "isAlive", pid };
|
return new String[] {Shell.getWinUtilsPath(), "task", "isAlive", pid };
|
||||||
} else {
|
} else {
|
||||||
return new String[] {Shell.getWinutilsPath(), "task", "kill", pid };
|
return new String[] {Shell.getWinUtilsPath(), "task", "kill", pid };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,7 +590,7 @@ public abstract class Shell {
|
||||||
* The lack of such checks has led to many support issues being raised.
|
* The lack of such checks has led to many support issues being raised.
|
||||||
* <p>
|
* <p>
|
||||||
* @deprecated use one of the exception-raising getter methods,
|
* @deprecated use one of the exception-raising getter methods,
|
||||||
* specifically {@link #getWinutilsPath()} or {@link #getWinutilsFile()}
|
* specifically {@link #getWinUtilsPath()} or {@link #getWinUtilsFile()}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static final String WINUTILS;
|
public static final String WINUTILS;
|
||||||
|
@ -646,7 +646,7 @@ public abstract class Shell {
|
||||||
* Predicate to indicate whether or not the path to winutils is known.
|
* Predicate to indicate whether or not the path to winutils is known.
|
||||||
*
|
*
|
||||||
* If true, then {@link #WINUTILS} is non-null, and both
|
* If true, then {@link #WINUTILS} is non-null, and both
|
||||||
* {@link #getWinutilsPath()} and {@link #getWinutilsFile()}
|
* {@link #getWinUtilsPath()} and {@link #getWinUtilsFile()}
|
||||||
* will successfully return this value. Always false on non-windows systems.
|
* will successfully return this value. Always false on non-windows systems.
|
||||||
* @return true if there is a valid path to the binary
|
* @return true if there is a valid path to the binary
|
||||||
*/
|
*/
|
||||||
|
@ -662,7 +662,7 @@ public abstract class Shell {
|
||||||
* @return the path to {@link #WINUTILS_EXE}
|
* @return the path to {@link #WINUTILS_EXE}
|
||||||
* @throws RuntimeException if the path is not resolvable
|
* @throws RuntimeException if the path is not resolvable
|
||||||
*/
|
*/
|
||||||
public static String getWinutilsPath() {
|
public static String getWinUtilsPath() {
|
||||||
if (WINUTILS_FAILURE == null) {
|
if (WINUTILS_FAILURE == null) {
|
||||||
return WINUTILS_PATH;
|
return WINUTILS_PATH;
|
||||||
} else {
|
} else {
|
||||||
|
@ -677,7 +677,7 @@ public abstract class Shell {
|
||||||
* @return the file instance referring to the winutils bin.
|
* @return the file instance referring to the winutils bin.
|
||||||
* @throws FileNotFoundException on any failure to locate that file.
|
* @throws FileNotFoundException on any failure to locate that file.
|
||||||
*/
|
*/
|
||||||
public static File getWinutilsFile() throws FileNotFoundException {
|
public static File getWinUtilsFile() throws FileNotFoundException {
|
||||||
if (WINUTILS_FAILURE == null) {
|
if (WINUTILS_FAILURE == null) {
|
||||||
return WINUTILS_FILE;
|
return WINUTILS_FILE;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class SysInfoWindows extends SysInfo {
|
||||||
String getSystemInfoInfoFromShell() {
|
String getSystemInfoInfoFromShell() {
|
||||||
try {
|
try {
|
||||||
ShellCommandExecutor shellExecutor = new ShellCommandExecutor(
|
ShellCommandExecutor shellExecutor = new ShellCommandExecutor(
|
||||||
new String[] {Shell.getWinutilsFile().getCanonicalPath(),
|
new String[] {Shell.getWinUtilsFile().getCanonicalPath(),
|
||||||
"systeminfo" });
|
"systeminfo" });
|
||||||
shellExecutor.execute();
|
shellExecutor.execute();
|
||||||
return shellExecutor.getOutput();
|
return shellExecutor.getOutput();
|
||||||
|
|
|
@ -217,7 +217,7 @@ public class TestUserGroupInformation {
|
||||||
}
|
}
|
||||||
// get the groups
|
// get the groups
|
||||||
pp = Runtime.getRuntime().exec(Shell.WINDOWS ?
|
pp = Runtime.getRuntime().exec(Shell.WINDOWS ?
|
||||||
Shell.getWinutilsPath() + " groups -F"
|
Shell.getWinUtilsPath() + " groups -F"
|
||||||
: "id -Gn");
|
: "id -Gn");
|
||||||
br = new BufferedReader(new InputStreamReader(pp.getInputStream()));
|
br = new BufferedReader(new InputStreamReader(pp.getInputStream()));
|
||||||
String line = br.readLine();
|
String line = br.readLine();
|
||||||
|
|
|
@ -194,7 +194,7 @@ public class TestShell extends Assert {
|
||||||
|
|
||||||
if (Shell.WINDOWS) {
|
if (Shell.WINDOWS) {
|
||||||
expectedCommand =
|
expectedCommand =
|
||||||
new String[]{getWinutilsPath(), "task", "isAlive", anyPid };
|
new String[]{getWinUtilsPath(), "task", "isAlive", anyPid };
|
||||||
} else if (Shell.isSetsidAvailable) {
|
} else if (Shell.isSetsidAvailable) {
|
||||||
expectedCommand = new String[] { "bash", "-c", "kill -0 -- -" + anyPid };
|
expectedCommand = new String[] { "bash", "-c", "kill -0 -- -" + anyPid };
|
||||||
} else {
|
} else {
|
||||||
|
@ -214,7 +214,7 @@ public class TestShell extends Assert {
|
||||||
|
|
||||||
if (Shell.WINDOWS) {
|
if (Shell.WINDOWS) {
|
||||||
expectedCommand =
|
expectedCommand =
|
||||||
new String[]{getWinutilsPath(), "task", "kill", anyPid };
|
new String[]{getWinUtilsPath(), "task", "kill", anyPid };
|
||||||
} else if (Shell.isSetsidAvailable) {
|
} else if (Shell.isSetsidAvailable) {
|
||||||
expectedCommand = new String[] { "bash", "-c", "kill -9 -- -" + anyPid };
|
expectedCommand = new String[] { "bash", "-c", "kill -9 -- -" + anyPid };
|
||||||
} else {
|
} else {
|
||||||
|
@ -342,12 +342,12 @@ public class TestShell extends Assert {
|
||||||
public void testNoWinutilsOnUnix() throws Throwable {
|
public void testNoWinutilsOnUnix() throws Throwable {
|
||||||
Assume.assumeFalse(WINDOWS);
|
Assume.assumeFalse(WINDOWS);
|
||||||
try {
|
try {
|
||||||
getWinutilsFile();
|
getWinUtilsFile();
|
||||||
} catch (FileNotFoundException ex) {
|
} catch (FileNotFoundException ex) {
|
||||||
assertExContains(ex, E_NOT_A_WINDOWS_SYSTEM);
|
assertExContains(ex, E_NOT_A_WINDOWS_SYSTEM);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
getWinutilsPath();
|
getWinUtilsPath();
|
||||||
} catch (RuntimeException ex) {
|
} catch (RuntimeException ex) {
|
||||||
assertExContains(ex, E_NOT_A_WINDOWS_SYSTEM);
|
assertExContains(ex, E_NOT_A_WINDOWS_SYSTEM);
|
||||||
if ( ex.getCause() == null
|
if ( ex.getCause() == null
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class TestWinUtils {
|
||||||
TEST_DIR.mkdirs();
|
TEST_DIR.mkdirs();
|
||||||
assertTrue("Failed to create Test directory " + TEST_DIR,
|
assertTrue("Failed to create Test directory " + TEST_DIR,
|
||||||
TEST_DIR.isDirectory() );
|
TEST_DIR.isDirectory() );
|
||||||
winutils = Shell.getWinutilsPath();
|
winutils = Shell.getWinUtilsPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
@ -65,7 +65,7 @@ public class TestWinUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void requireWinutils() throws IOException {
|
private void requireWinutils() throws IOException {
|
||||||
Shell.getWinutilsPath();
|
Shell.getWinUtilsPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper routine that writes the given content to the file.
|
// Helper routine that writes the given content to the file.
|
||||||
|
@ -280,7 +280,7 @@ public class TestWinUtils {
|
||||||
// - Change mode to 677 so owner does not have execute permission.
|
// - Change mode to 677 so owner does not have execute permission.
|
||||||
// - Verify the owner truly does not have the permissions to execute the file.
|
// - Verify the owner truly does not have the permissions to execute the file.
|
||||||
|
|
||||||
File winutilsFile = Shell.getWinutilsFile();
|
File winutilsFile = Shell.getWinUtilsFile();
|
||||||
File aExe = new File(TEST_DIR, "a.exe");
|
File aExe = new File(TEST_DIR, "a.exe");
|
||||||
FileUtils.copyFile(winutilsFile, aExe);
|
FileUtils.copyFile(winutilsFile, aExe);
|
||||||
chmod("677", aExe);
|
chmod("677", aExe);
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class WindowsBasedProcessTree extends ResourceCalculatorProcessTree {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ShellCommandExecutor shellExecutor = new ShellCommandExecutor(
|
ShellCommandExecutor shellExecutor = new ShellCommandExecutor(
|
||||||
new String[] { Shell.getWinutilsPath(), "help" });
|
new String[] { Shell.getWinUtilsPath(), "help" });
|
||||||
try {
|
try {
|
||||||
shellExecutor.execute();
|
shellExecutor.execute();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -80,7 +80,7 @@ public class WindowsBasedProcessTree extends ResourceCalculatorProcessTree {
|
||||||
String getAllProcessInfoFromShell() {
|
String getAllProcessInfoFromShell() {
|
||||||
try {
|
try {
|
||||||
ShellCommandExecutor shellExecutor = new ShellCommandExecutor(
|
ShellCommandExecutor shellExecutor = new ShellCommandExecutor(
|
||||||
new String[] {Shell.getWinutilsFile().getCanonicalPath(),
|
new String[] {Shell.getWinUtilsFile().getCanonicalPath(),
|
||||||
"task", "processList", taskProcessId });
|
"task", "processList", taskProcessId });
|
||||||
shellExecutor.execute();
|
shellExecutor.execute();
|
||||||
return shellExecutor.getOutput();
|
return shellExecutor.getOutput();
|
||||||
|
|
|
@ -401,7 +401,7 @@ public abstract class ContainerExecutor implements Configurable {
|
||||||
cpuRate = Math.min(10000, (int) (containerCpuPercentage * 100));
|
cpuRate = Math.min(10000, (int) (containerCpuPercentage * 100));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new String[] { Shell.getWinutilsPath(), "task", "create", "-m",
|
return new String[] { Shell.getWinUtilsPath(), "task", "create", "-m",
|
||||||
String.valueOf(memory), "-c", String.valueOf(cpuRate), groupId,
|
String.valueOf(memory), "-c", String.valueOf(cpuRate), groupId,
|
||||||
"cmd /c " + command };
|
"cmd /c " + command };
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -578,7 +578,7 @@ public class WindowsSecureContainerExecutor extends DefaultContainerExecutor {
|
||||||
LOG.debug(String.format("getRunCommand: %s exists:%b",
|
LOG.debug(String.format("getRunCommand: %s exists:%b",
|
||||||
command, f.exists()));
|
command, f.exists()));
|
||||||
}
|
}
|
||||||
return new String[] { Shell.getWinutilsPath(), "task",
|
return new String[] { Shell.getWinUtilsPath(), "task",
|
||||||
"createAsUser", groupId,
|
"createAsUser", groupId,
|
||||||
userName, pidFile.toString(), "cmd /c " + command };
|
userName, pidFile.toString(), "cmd /c " + command };
|
||||||
}
|
}
|
||||||
|
|
|
@ -747,7 +747,7 @@ public class ContainerLaunch implements Callable<Integer> {
|
||||||
String srcFileStr = srcFile.getPath();
|
String srcFileStr = srcFile.getPath();
|
||||||
String dstFileStr = new File(dst.toString()).getPath();
|
String dstFileStr = new File(dst.toString()).getPath();
|
||||||
lineWithLenCheck(String.format("@%s symlink \"%s\" \"%s\"",
|
lineWithLenCheck(String.format("@%s symlink \"%s\" \"%s\"",
|
||||||
Shell.getWinutilsPath(), dstFileStr, srcFileStr));
|
Shell.getWinUtilsPath(), dstFileStr, srcFileStr));
|
||||||
errorCheck();
|
errorCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1072,7 +1072,7 @@ public class TestContainerLaunch extends BaseContainerManagerTest {
|
||||||
public void testWindowsShellScriptBuilderLink() throws IOException {
|
public void testWindowsShellScriptBuilderLink() throws IOException {
|
||||||
// Test is only relevant on Windows
|
// Test is only relevant on Windows
|
||||||
Assume.assumeTrue(Shell.WINDOWS);
|
Assume.assumeTrue(Shell.WINDOWS);
|
||||||
String linkCmd = "@" + Shell.getWinutilsPath() + " symlink \"\" \"\"";
|
String linkCmd = "@" + Shell.getWinUtilsPath() + " symlink \"\" \"\"";
|
||||||
|
|
||||||
// The tests are built on assuming 8191 max command line length
|
// The tests are built on assuming 8191 max command line length
|
||||||
assertEquals(8191, Shell.WINDOWS_MAX_SHELL_LENGTH);
|
assertEquals(8191, Shell.WINDOWS_MAX_SHELL_LENGTH);
|
||||||
|
|
Loading…
Reference in New Issue