|
@@ -34,7 +34,6 @@ import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Cont
|
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerExitEvent;
|
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerExitEvent;
|
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.ContainerLocalizer;
|
|
import org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.ContainerLocalizer;
|
|
import org.apache.hadoop.yarn.server.nodemanager.executor.ContainerStartContext;
|
|
import org.apache.hadoop.yarn.server.nodemanager.executor.ContainerStartContext;
|
|
-import org.apache.hadoop.yarn.server.nodemanager.executor.DeletionAsUserContext;
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
@@ -71,7 +70,8 @@ public class ContainerRelaunch extends ContainerLaunch {
|
|
Path containerLogDir;
|
|
Path containerLogDir;
|
|
try {
|
|
try {
|
|
Path containerWorkDir = getContainerWorkDir();
|
|
Path containerWorkDir = getContainerWorkDir();
|
|
- cleanupPreviousContainerFiles(containerWorkDir);
|
|
|
|
|
|
+ // Clean up container's previous files for container relaunch.
|
|
|
|
+ cleanupContainerFiles(containerWorkDir);
|
|
|
|
|
|
containerLogDir = getContainerLogDir();
|
|
containerLogDir = getContainerLogDir();
|
|
|
|
|
|
@@ -148,17 +148,6 @@ public class ContainerRelaunch extends ContainerLaunch {
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
- private Path getContainerWorkDir() throws IOException {
|
|
|
|
- String containerWorkDir = container.getWorkDir();
|
|
|
|
- if (containerWorkDir == null
|
|
|
|
- || !dirsHandler.isGoodLocalDir(containerWorkDir)) {
|
|
|
|
- throw new IOException(
|
|
|
|
- "Could not find a good work dir " + containerWorkDir
|
|
|
|
- + " for container " + container);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return new Path(containerWorkDir);
|
|
|
|
- }
|
|
|
|
|
|
|
|
private Path getContainerLogDir() throws IOException {
|
|
private Path getContainerLogDir() throws IOException {
|
|
String containerLogDir = container.getLogDir();
|
|
String containerLogDir = container.getLogDir();
|
|
@@ -190,25 +179,4 @@ public class ContainerRelaunch extends ContainerLaunch {
|
|
return dirsHandler.getLocalPathForRead(
|
|
return dirsHandler.getLocalPathForRead(
|
|
getPidFileSubpath(appIdStr, containerIdStr));
|
|
getPidFileSubpath(appIdStr, containerIdStr));
|
|
}
|
|
}
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Clean up container's previous files for container relaunch.
|
|
|
|
- */
|
|
|
|
- private void cleanupPreviousContainerFiles(Path containerWorkDir) {
|
|
|
|
- // delete ContainerScriptPath
|
|
|
|
- deleteAsUser(new Path(containerWorkDir, CONTAINER_SCRIPT));
|
|
|
|
- // delete TokensPath
|
|
|
|
- deleteAsUser(new Path(containerWorkDir, FINAL_CONTAINER_TOKENS_FILE));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void deleteAsUser(Path path) {
|
|
|
|
- try {
|
|
|
|
- exec.deleteAsUser(new DeletionAsUserContext.Builder()
|
|
|
|
- .setUser(container.getUser())
|
|
|
|
- .setSubDir(path)
|
|
|
|
- .build());
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- LOG.warn("Failed to delete " + path, e);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
}
|
|
}
|