HADOOP-12478. Shell.getWinUtilsPath() has been renamed Shell.getWinutilsPath(). (stevel)
This commit is contained in:
parent
ab13aa30cb
commit
dfa7848463
|
@ -1225,6 +1225,9 @@ Release 2.8.0 - UNRELEASED
|
|||
HADOOP-11515. Upgrade jsch lib to jsch-0.1.51 to avoid problems running
|
||||
on java7. (stevel and ozawa)
|
||||
|
||||
HADOOP-12478. Shell.getWinUtilsPath() has been renamed
|
||||
Shell.getWinutilsPath(). (stevel)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
HADOOP-12051. ProtobufRpcEngine.invoke() should use Exception.toString()
|
||||
|
|
|
@ -137,7 +137,7 @@ public class HardLink {
|
|||
@Override
|
||||
String[] linkCount(File file) throws IOException {
|
||||
// trigger the check for winutils
|
||||
Shell.getWinutilsFile();
|
||||
Shell.getWinUtilsFile();
|
||||
String[] buf = new String[getLinkCountCommand.length];
|
||||
System.arraycopy(getLinkCountCommand, 0, buf, 0,
|
||||
getLinkCountCommand.length);
|
||||
|
|
|
@ -108,7 +108,7 @@ public class NativeLibraryChecker {
|
|||
if (Shell.WINDOWS) {
|
||||
// winutils.exe is required on Windows
|
||||
try {
|
||||
winutilsPath = Shell.getWinutilsFile().getCanonicalPath();
|
||||
winutilsPath = Shell.getWinUtilsFile().getCanonicalPath();
|
||||
winutilsExists = true;
|
||||
} catch (IOException e) {
|
||||
LOG.debug("No Winutils: ", e);
|
||||
|
|
|
@ -185,7 +185,7 @@ public abstract class Shell {
|
|||
//'groups username' command return is inconsistent across different unixes
|
||||
return WINDOWS ?
|
||||
new String[]
|
||||
{ getWinutilsPath(), "groups", "-F", "\"" + user + "\"" }
|
||||
{ getWinUtilsPath(), "groups", "-F", "\"" + 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. */
|
||||
public static String[] getGetPermissionCommand() {
|
||||
return (WINDOWS) ? new String[] { getWinutilsPath(), "ls", "-F" }
|
||||
return (WINDOWS) ? new String[] { getWinUtilsPath(), "ls", "-F" }
|
||||
: new String[] { "/bin/ls", "-ld" };
|
||||
}
|
||||
|
||||
|
@ -206,11 +206,11 @@ public abstract class Shell {
|
|||
public static String[] getSetPermissionCommand(String perm, boolean recursive) {
|
||||
if (recursive) {
|
||||
return (WINDOWS) ?
|
||||
new String[] { getWinutilsPath(), "chmod", "-R", perm }
|
||||
new String[] { getWinUtilsPath(), "chmod", "-R", perm }
|
||||
: new String[] { "chmod", "-R", perm };
|
||||
} else {
|
||||
return (WINDOWS) ?
|
||||
new String[] { getWinutilsPath(), "chmod", perm }
|
||||
new String[] { getWinUtilsPath(), "chmod", perm }
|
||||
: new String[] { "chmod", perm };
|
||||
}
|
||||
}
|
||||
|
@ -234,21 +234,21 @@ public abstract class Shell {
|
|||
/** Return a command to set owner. */
|
||||
public static String[] getSetOwnerCommand(String owner) {
|
||||
return (WINDOWS) ?
|
||||
new String[] { getWinutilsPath(), "chown", "\"" + owner + "\"" }
|
||||
new String[] { getWinUtilsPath(), "chown", "\"" + owner + "\"" }
|
||||
: new String[] { "chown", owner };
|
||||
}
|
||||
|
||||
/** Return a command to create symbolic links. */
|
||||
public static String[] getSymlinkCommand(String target, String link) {
|
||||
return WINDOWS ?
|
||||
new String[] { getWinutilsPath(), "symlink", link, target }
|
||||
new String[] { getWinUtilsPath(), "symlink", link, target }
|
||||
: new String[] { "ln", "-s", target, link };
|
||||
}
|
||||
|
||||
/** Return a command to read the target of the a symbolic link. */
|
||||
public static String[] getReadlinkCommand(String link) {
|
||||
return WINDOWS ?
|
||||
new String[] { getWinutilsPath(), "readlink", link }
|
||||
new String[] { getWinUtilsPath(), "readlink", link }
|
||||
: new String[] { "readlink", link };
|
||||
}
|
||||
|
||||
|
@ -266,9 +266,9 @@ public abstract class Shell {
|
|||
// Code == 0 means check alive
|
||||
if (Shell.WINDOWS) {
|
||||
if (0 == code) {
|
||||
return new String[] {Shell.getWinutilsPath(), "task", "isAlive", pid };
|
||||
return new String[] {Shell.getWinUtilsPath(), "task", "isAlive", pid };
|
||||
} 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.
|
||||
* <p>
|
||||
* @deprecated use one of the exception-raising getter methods,
|
||||
* specifically {@link #getWinutilsPath()} or {@link #getWinutilsFile()}
|
||||
* specifically {@link #getWinUtilsPath()} or {@link #getWinUtilsFile()}
|
||||
*/
|
||||
@Deprecated
|
||||
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.
|
||||
*
|
||||
* 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.
|
||||
* @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}
|
||||
* @throws RuntimeException if the path is not resolvable
|
||||
*/
|
||||
public static String getWinutilsPath() {
|
||||
public static String getWinUtilsPath() {
|
||||
if (WINUTILS_FAILURE == null) {
|
||||
return WINUTILS_PATH;
|
||||
} else {
|
||||
|
@ -677,7 +677,7 @@ public abstract class Shell {
|
|||
* @return the file instance referring to the winutils bin.
|
||||
* @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) {
|
||||
return WINUTILS_FILE;
|
||||
} else {
|
||||
|
|
|
@ -72,7 +72,7 @@ public class SysInfoWindows extends SysInfo {
|
|||
String getSystemInfoInfoFromShell() {
|
||||
try {
|
||||
ShellCommandExecutor shellExecutor = new ShellCommandExecutor(
|
||||
new String[] {Shell.getWinutilsFile().getCanonicalPath(),
|
||||
new String[] {Shell.getWinUtilsFile().getCanonicalPath(),
|
||||
"systeminfo" });
|
||||
shellExecutor.execute();
|
||||
return shellExecutor.getOutput();
|
||||
|
|
|
@ -218,7 +218,7 @@ public class TestUserGroupInformation {
|
|||
}
|
||||
// get the groups
|
||||
pp = Runtime.getRuntime().exec(Shell.WINDOWS ?
|
||||
Shell.getWinutilsPath() + " groups -F"
|
||||
Shell.getWinUtilsPath() + " groups -F"
|
||||
: "id -Gn");
|
||||
br = new BufferedReader(new InputStreamReader(pp.getInputStream()));
|
||||
String line = br.readLine();
|
||||
|
|
|
@ -194,7 +194,7 @@ public class TestShell extends Assert {
|
|||
|
||||
if (Shell.WINDOWS) {
|
||||
expectedCommand =
|
||||
new String[]{getWinutilsPath(), "task", "isAlive", anyPid };
|
||||
new String[]{getWinUtilsPath(), "task", "isAlive", anyPid };
|
||||
} else if (Shell.isSetsidAvailable) {
|
||||
expectedCommand = new String[] { "bash", "-c", "kill -0 -- -" + anyPid };
|
||||
} else {
|
||||
|
@ -214,7 +214,7 @@ public class TestShell extends Assert {
|
|||
|
||||
if (Shell.WINDOWS) {
|
||||
expectedCommand =
|
||||
new String[]{getWinutilsPath(), "task", "kill", anyPid };
|
||||
new String[]{getWinUtilsPath(), "task", "kill", anyPid };
|
||||
} else if (Shell.isSetsidAvailable) {
|
||||
expectedCommand = new String[] { "bash", "-c", "kill -9 -- -" + anyPid };
|
||||
} else {
|
||||
|
@ -342,12 +342,12 @@ public class TestShell extends Assert {
|
|||
public void testNoWinutilsOnUnix() throws Throwable {
|
||||
Assume.assumeFalse(WINDOWS);
|
||||
try {
|
||||
getWinutilsFile();
|
||||
getWinUtilsFile();
|
||||
} catch (FileNotFoundException ex) {
|
||||
assertExContains(ex, E_NOT_A_WINDOWS_SYSTEM);
|
||||
}
|
||||
try {
|
||||
getWinutilsPath();
|
||||
getWinUtilsPath();
|
||||
} catch (RuntimeException ex) {
|
||||
assertExContains(ex, E_NOT_A_WINDOWS_SYSTEM);
|
||||
if ( ex.getCause() == null
|
||||
|
|
|
@ -56,7 +56,7 @@ public class TestWinUtils {
|
|||
TEST_DIR.mkdirs();
|
||||
assertTrue("Failed to create Test directory " + TEST_DIR,
|
||||
TEST_DIR.isDirectory() );
|
||||
winutils = Shell.getWinutilsPath();
|
||||
winutils = Shell.getWinUtilsPath();
|
||||
}
|
||||
|
||||
@After
|
||||
|
@ -65,7 +65,7 @@ public class TestWinUtils {
|
|||
}
|
||||
|
||||
private void requireWinutils() throws IOException {
|
||||
Shell.getWinutilsPath();
|
||||
Shell.getWinUtilsPath();
|
||||
}
|
||||
|
||||
// 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.
|
||||
// - 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");
|
||||
FileUtils.copyFile(winutilsFile, aExe);
|
||||
chmod("677", aExe);
|
||||
|
|
|
@ -55,7 +55,7 @@ public class WindowsBasedProcessTree extends ResourceCalculatorProcessTree {
|
|||
return false;
|
||||
}
|
||||
ShellCommandExecutor shellExecutor = new ShellCommandExecutor(
|
||||
new String[] { Shell.getWinutilsPath(), "help" });
|
||||
new String[] { Shell.getWinUtilsPath(), "help" });
|
||||
try {
|
||||
shellExecutor.execute();
|
||||
} catch (IOException e) {
|
||||
|
@ -80,7 +80,7 @@ public class WindowsBasedProcessTree extends ResourceCalculatorProcessTree {
|
|||
String getAllProcessInfoFromShell() {
|
||||
try {
|
||||
ShellCommandExecutor shellExecutor = new ShellCommandExecutor(
|
||||
new String[] {Shell.getWinutilsFile().getCanonicalPath(),
|
||||
new String[] {Shell.getWinUtilsFile().getCanonicalPath(),
|
||||
"task", "processList", taskProcessId });
|
||||
shellExecutor.execute();
|
||||
return shellExecutor.getOutput();
|
||||
|
|
|
@ -401,7 +401,7 @@ public abstract class ContainerExecutor implements Configurable {
|
|||
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,
|
||||
"cmd /c " + command };
|
||||
} else {
|
||||
|
|
|
@ -578,7 +578,7 @@ public class WindowsSecureContainerExecutor extends DefaultContainerExecutor {
|
|||
LOG.debug(String.format("getRunCommand: %s exists:%b",
|
||||
command, f.exists()));
|
||||
}
|
||||
return new String[] { Shell.getWinutilsPath(), "task",
|
||||
return new String[] { Shell.getWinUtilsPath(), "task",
|
||||
"createAsUser", groupId,
|
||||
userName, pidFile.toString(), "cmd /c " + command };
|
||||
}
|
||||
|
|
|
@ -747,7 +747,7 @@ public class ContainerLaunch implements Callable<Integer> {
|
|||
String srcFileStr = srcFile.getPath();
|
||||
String dstFileStr = new File(dst.toString()).getPath();
|
||||
lineWithLenCheck(String.format("@%s symlink \"%s\" \"%s\"",
|
||||
Shell.getWinutilsPath(), dstFileStr, srcFileStr));
|
||||
Shell.getWinUtilsPath(), dstFileStr, srcFileStr));
|
||||
errorCheck();
|
||||
}
|
||||
|
||||
|
|
|
@ -1072,7 +1072,7 @@ public class TestContainerLaunch extends BaseContainerManagerTest {
|
|||
public void testWindowsShellScriptBuilderLink() throws IOException {
|
||||
// Test is only relevant on 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
|
||||
assertEquals(8191, Shell.WINDOWS_MAX_SHELL_LENGTH);
|
||||
|
|
Loading…
Reference in New Issue