HADOOP-6192. Fix Shell.getUlimitMemoryCommand to not rely on Map-Reduce specific configs.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@804115 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Arun Murthy 2009-08-14 08:16:10 +00:00
parent 38a84a6c98
commit ec8208f5d3
2 changed files with 32 additions and 2 deletions

View File

@ -917,6 +917,9 @@ Trunk (unreleased changes)
HADOOP-6188. TestTrash uses java.io.File api but not hadoop FileSystem api.
(Boris Shkolnik via szetszwo)
HADOOP-6192. Fix Shell.getUlimitMemoryCommand to not rely on Map-Reduce
specific configs. (acmurthy)
Release 0.20.1 - Unreleased
INCOMPATIBLE CHANGES

View File

@ -63,6 +63,31 @@ public static String[] getGET_PERMISSION_COMMAND() {
/** If or not script timed out*/
private AtomicBoolean timedOut;
/** a Unix command to get ulimit of a process. */
public static final String ULIMIT_COMMAND = "ulimit";
/**
* Get the Unix command for setting the maximum virtual memory available
* to a given child process. This is only relevant when we are forking a
* process from within the Mapper or the Reducer implementations.
* Also see Hadoop Pipes and Hadoop Streaming.
*
* It also checks to ensure that we are running on a *nix platform else
* (e.g. in Cygwin/Windows) it returns <code>null</code>.
* @param memoryLimit virtual memory limit
* @return a <code>String[]</code> with the ulimit command arguments or
* <code>null</code> if we are running on a non *nix platform or
* if the limit is unspecified.
*/
public static String[] getUlimitMemoryCommand(int memoryLimit) {
// ulimit isn't supported on Windows
if (WINDOWS) {
return null;
}
return new String[] {ULIMIT_COMMAND, "-v", String.valueOf(memoryLimit)};
}
/**
* Get the Unix command for setting the maximum virtual memory available
* to a given child process. This is only relevant when we are forking a
@ -75,7 +100,9 @@ public static String[] getGET_PERMISSION_COMMAND() {
* @return a <code>String[]</code> with the ulimit command arguments or
* <code>null</code> if we are running on a non *nix platform or
* if the limit is unspecified.
* @deprecated Use {@link #getUlimitMemoryCommand(int)}
*/
@Deprecated
public static String[] getUlimitMemoryCommand(Configuration conf) {
// ulimit isn't supported on Windows
if (WINDOWS) {
@ -91,7 +118,7 @@ public static String[] getUlimitMemoryCommand(Configuration conf) {
// Parse it to ensure it is legal/sane
int memoryLimit = Integer.valueOf(ulimit);
return new String[] {"ulimit", "-v", String.valueOf(memoryLimit)};
return getUlimitMemoryCommand(memoryLimit);
}
/** Set to true on Windows platforms */