YARN-781. Exposing LOGDIR in all containers' environment which should be used by containers for logging purposes. Contributed by Jian He.
svn merge --ignore-ancestry -c 1493428 ../../trunk/ git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1493429 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
dc8d2412fe
commit
ef1ee646b6
|
@ -156,6 +156,9 @@ Release 2.1.0-beta - UNRELEASED
|
||||||
YARN-398. Make it possible to specify hard locality constraints in resource
|
YARN-398. Make it possible to specify hard locality constraints in resource
|
||||||
requests for CapacityScheduler. (acmurthy)
|
requests for CapacityScheduler. (acmurthy)
|
||||||
|
|
||||||
|
YARN-781. Exposing LOGDIR in all containers' environment which should be used
|
||||||
|
by containers for logging purposes. (Jian He via vinodkv)
|
||||||
|
|
||||||
IMPROVEMENTS
|
IMPROVEMENTS
|
||||||
|
|
||||||
YARN-365. Change NM heartbeat handling to not generate a scheduler event
|
YARN-365. Change NM heartbeat handling to not generate a scheduler event
|
||||||
|
|
|
@ -177,7 +177,15 @@ public interface ApplicationConstants {
|
||||||
* $LOCAL_DIRS
|
* $LOCAL_DIRS
|
||||||
* Final, exported by NodeManager and non-modifiable by users.
|
* Final, exported by NodeManager and non-modifiable by users.
|
||||||
*/
|
*/
|
||||||
LOCAL_DIRS("LOCAL_DIRS");
|
LOCAL_DIRS("LOCAL_DIRS"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* $LOG_DIRS
|
||||||
|
* Final, exported by NodeManager and non-modifiable by users.
|
||||||
|
* Comma separate list of directories that the container should use for
|
||||||
|
* logging.
|
||||||
|
*/
|
||||||
|
LOG_DIRS("LOG_DIRS");
|
||||||
|
|
||||||
private final String variable;
|
private final String variable;
|
||||||
private Environment(String variable) {
|
private Environment(String variable) {
|
||||||
|
|
|
@ -132,9 +132,10 @@ public class ContainerLaunch implements Callable<Integer> {
|
||||||
// Before the container script gets written out.
|
// Before the container script gets written out.
|
||||||
List<String> newCmds = new ArrayList<String>(command.size());
|
List<String> newCmds = new ArrayList<String>(command.size());
|
||||||
String appIdStr = app.getAppId().toString();
|
String appIdStr = app.getAppId().toString();
|
||||||
|
String relativeContainerLogDir = ContainerLaunch
|
||||||
|
.getRelativeContainerLogDir(appIdStr, containerIdStr);
|
||||||
Path containerLogDir =
|
Path containerLogDir =
|
||||||
dirsHandler.getLogPathForWrite(ContainerLaunch
|
dirsHandler.getLogPathForWrite(relativeContainerLogDir, false);
|
||||||
.getRelativeContainerLogDir(appIdStr, containerIdStr), false);
|
|
||||||
for (String str : command) {
|
for (String str : command) {
|
||||||
// TODO: Should we instead work via symlinks without this grammar?
|
// TODO: Should we instead work via symlinks without this grammar?
|
||||||
newCmds.add(str.replace(ApplicationConstants.LOG_DIR_EXPANSION_VAR,
|
newCmds.add(str.replace(ApplicationConstants.LOG_DIR_EXPANSION_VAR,
|
||||||
|
@ -189,6 +190,11 @@ public class ContainerLaunch implements Callable<Integer> {
|
||||||
List<String> localDirs = dirsHandler.getLocalDirs();
|
List<String> localDirs = dirsHandler.getLocalDirs();
|
||||||
List<String> logDirs = dirsHandler.getLogDirs();
|
List<String> logDirs = dirsHandler.getLogDirs();
|
||||||
|
|
||||||
|
List<String> containerLogDirs = new ArrayList<String>();
|
||||||
|
for( String logDir : logDirs) {
|
||||||
|
containerLogDirs.add(logDir + Path.SEPARATOR + relativeContainerLogDir);
|
||||||
|
}
|
||||||
|
|
||||||
if (!dirsHandler.areDisksHealthy()) {
|
if (!dirsHandler.areDisksHealthy()) {
|
||||||
ret = ContainerExitStatus.DISKS_FAILED;
|
ret = ContainerExitStatus.DISKS_FAILED;
|
||||||
throw new IOException("Most of the disks failed. "
|
throw new IOException("Most of the disks failed. "
|
||||||
|
@ -215,7 +221,8 @@ public class ContainerLaunch implements Callable<Integer> {
|
||||||
FINAL_CONTAINER_TOKENS_FILE).toUri().getPath());
|
FINAL_CONTAINER_TOKENS_FILE).toUri().getPath());
|
||||||
|
|
||||||
// Sanitize the container's environment
|
// Sanitize the container's environment
|
||||||
sanitizeEnv(environment, containerWorkDir, appDirs, localResources);
|
sanitizeEnv(environment, containerWorkDir, appDirs, containerLogDirs,
|
||||||
|
localResources);
|
||||||
|
|
||||||
// Write out the environment
|
// Write out the environment
|
||||||
writeLaunchEnv(containerScriptOutStream, environment, localResources,
|
writeLaunchEnv(containerScriptOutStream, environment, localResources,
|
||||||
|
@ -543,9 +550,9 @@ public class ContainerLaunch implements Callable<Integer> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sanitizeEnv(Map<String, String> environment,
|
public void sanitizeEnv(Map<String, String> environment, Path pwd,
|
||||||
Path pwd, List<Path> appDirs, Map<Path, List<String>> resources)
|
List<Path> appDirs, List<String> containerLogDirs,
|
||||||
throws IOException {
|
Map<Path, List<String>> resources) throws IOException {
|
||||||
/**
|
/**
|
||||||
* Non-modifiable environment variables
|
* Non-modifiable environment variables
|
||||||
*/
|
*/
|
||||||
|
@ -565,6 +572,9 @@ public class ContainerLaunch implements Callable<Integer> {
|
||||||
environment.put(Environment.LOCAL_DIRS.name(),
|
environment.put(Environment.LOCAL_DIRS.name(),
|
||||||
StringUtils.join(",", appDirs));
|
StringUtils.join(",", appDirs));
|
||||||
|
|
||||||
|
environment.put(Environment.LOG_DIRS.name(),
|
||||||
|
StringUtils.join(",", containerLogDirs));
|
||||||
|
|
||||||
putEnvIfNotNull(environment, Environment.USER.name(), container.getUser());
|
putEnvIfNotNull(environment, Environment.USER.name(), container.getUser());
|
||||||
|
|
||||||
putEnvIfNotNull(environment,
|
putEnvIfNotNull(environment,
|
||||||
|
|
|
@ -250,6 +250,8 @@ public class TestContainerLaunch extends BaseContainerManagerTest {
|
||||||
|
|
||||||
// Now verify the contents of the file
|
// Now verify the contents of the file
|
||||||
List<String> localDirs = dirsHandler.getLocalDirs();
|
List<String> localDirs = dirsHandler.getLocalDirs();
|
||||||
|
List<String> logDirs = dirsHandler.getLogDirs();
|
||||||
|
|
||||||
List<Path> appDirs = new ArrayList<Path>(localDirs.size());
|
List<Path> appDirs = new ArrayList<Path>(localDirs.size());
|
||||||
for (String localDir : localDirs) {
|
for (String localDir : localDirs) {
|
||||||
Path usersdir = new Path(localDir, ContainerLocalizer.USERCACHE);
|
Path usersdir = new Path(localDir, ContainerLocalizer.USERCACHE);
|
||||||
|
@ -257,6 +259,12 @@ public class TestContainerLaunch extends BaseContainerManagerTest {
|
||||||
Path appsdir = new Path(userdir, ContainerLocalizer.APPCACHE);
|
Path appsdir = new Path(userdir, ContainerLocalizer.APPCACHE);
|
||||||
appDirs.add(new Path(appsdir, appId.toString()));
|
appDirs.add(new Path(appsdir, appId.toString()));
|
||||||
}
|
}
|
||||||
|
List<String> containerLogDirs = new ArrayList<String>();
|
||||||
|
String relativeContainerLogDir = ContainerLaunch
|
||||||
|
.getRelativeContainerLogDir(appId.toString(), cId.toString());
|
||||||
|
for(String logDir : logDirs){
|
||||||
|
containerLogDirs.add(logDir + Path.SEPARATOR + relativeContainerLogDir);
|
||||||
|
}
|
||||||
BufferedReader reader =
|
BufferedReader reader =
|
||||||
new BufferedReader(new FileReader(processStartFile));
|
new BufferedReader(new FileReader(processStartFile));
|
||||||
Assert.assertEquals(cId.toString(), reader.readLine());
|
Assert.assertEquals(cId.toString(), reader.readLine());
|
||||||
|
@ -276,6 +284,9 @@ public class TestContainerLaunch extends BaseContainerManagerTest {
|
||||||
.getEnvironment().get(Environment.NM_HTTP_PORT.name()));
|
.getEnvironment().get(Environment.NM_HTTP_PORT.name()));
|
||||||
Assert.assertEquals(StringUtils.join(",", appDirs), containerLaunchContext
|
Assert.assertEquals(StringUtils.join(",", appDirs), containerLaunchContext
|
||||||
.getEnvironment().get(Environment.LOCAL_DIRS.name()));
|
.getEnvironment().get(Environment.LOCAL_DIRS.name()));
|
||||||
|
Assert.assertEquals(StringUtils.join(",", containerLogDirs),
|
||||||
|
containerLaunchContext.getEnvironment().get(Environment.LOG_DIRS.name()));
|
||||||
|
|
||||||
// Get the pid of the process
|
// Get the pid of the process
|
||||||
String pid = reader.readLine().trim();
|
String pid = reader.readLine().trim();
|
||||||
// No more lines
|
// No more lines
|
||||||
|
|
Loading…
Reference in New Issue