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:
parent
38a84a6c98
commit
ec8208f5d3
|
@ -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
|
||||
|
|
|
@ -63,6 +63,31 @@ abstract public class Shell {
|
|||
/** 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 @@ abstract public class Shell {
|
|||
* @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) {
|
||||
|
@ -90,8 +117,8 @@ abstract public class Shell {
|
|||
|
||||
// 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 */
|
||||
|
|
Loading…
Reference in New Issue