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. HADOOP-6188. TestTrash uses java.io.File api but not hadoop FileSystem api.
(Boris Shkolnik via szetszwo) (Boris Shkolnik via szetszwo)
HADOOP-6192. Fix Shell.getUlimitMemoryCommand to not rely on Map-Reduce
specific configs. (acmurthy)
Release 0.20.1 - Unreleased Release 0.20.1 - Unreleased
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -63,6 +63,31 @@ public static String[] getGET_PERMISSION_COMMAND() {
/** If or not script timed out*/ /** If or not script timed out*/
private AtomicBoolean timedOut; 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 * 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 * 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 * @return a <code>String[]</code> with the ulimit command arguments or
* <code>null</code> if we are running on a non *nix platform or * <code>null</code> if we are running on a non *nix platform or
* if the limit is unspecified. * if the limit is unspecified.
* @deprecated Use {@link #getUlimitMemoryCommand(int)}
*/ */
@Deprecated
public static String[] getUlimitMemoryCommand(Configuration conf) { public static String[] getUlimitMemoryCommand(Configuration conf) {
// ulimit isn't supported on Windows // ulimit isn't supported on Windows
if (WINDOWS) { if (WINDOWS) {
@ -91,7 +118,7 @@ public static String[] getUlimitMemoryCommand(Configuration conf) {
// Parse it to ensure it is legal/sane // Parse it to ensure it is legal/sane
int memoryLimit = Integer.valueOf(ulimit); int memoryLimit = Integer.valueOf(ulimit);
return new String[] {"ulimit", "-v", String.valueOf(memoryLimit)}; return getUlimitMemoryCommand(memoryLimit);
} }
/** Set to true on Windows platforms */ /** Set to true on Windows platforms */