|
@@ -26,6 +26,7 @@ import java.net.InetAddress;
|
|
import java.net.UnknownHostException;
|
|
import java.net.UnknownHostException;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.LinkedHashSet;
|
|
import java.util.LinkedHashSet;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -34,6 +35,7 @@ import java.util.concurrent.ConcurrentMap;
|
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
|
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
|
|
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
|
|
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
|
|
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
|
|
|
|
+
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
@@ -415,20 +417,9 @@ public abstract class ContainerExecutor implements Configurable {
|
|
|
|
|
|
if (resources != null) {
|
|
if (resources != null) {
|
|
sb.echo("Setting up job resources");
|
|
sb.echo("Setting up job resources");
|
|
- for (Map.Entry<Path, List<String>> resourceEntry :
|
|
|
|
- resources.entrySet()) {
|
|
|
|
- for (String linkName : resourceEntry.getValue()) {
|
|
|
|
- if (new Path(linkName).getName().equals(WILDCARD)) {
|
|
|
|
- // If this is a wildcarded path, link to everything in the
|
|
|
|
- // directory from the working directory
|
|
|
|
- for (File wildLink : readDirAsUser(user, resourceEntry.getKey())) {
|
|
|
|
- sb.symlink(new Path(wildLink.toString()),
|
|
|
|
- new Path(wildLink.getName()));
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- sb.symlink(resourceEntry.getKey(), new Path(linkName));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ Map<Path, Path> symLinks = resolveSymLinks(resources, user);
|
|
|
|
+ for (Map.Entry<Path, Path> symLink : symLinks.entrySet()) {
|
|
|
|
+ sb.symlink(symLink.getKey(), symLink.getValue());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -789,6 +780,28 @@ public abstract class ContainerExecutor implements Configurable {
|
|
throw new UnsupportedOperationException();
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Perform any cleanup before the next launch of the container.
|
|
|
|
+ * @param container container
|
|
|
|
+ */
|
|
|
|
+ public void cleanupBeforeRelaunch(Container container)
|
|
|
|
+ throws IOException, InterruptedException {
|
|
|
|
+ if (container.getLocalizedResources() != null) {
|
|
|
|
+
|
|
|
|
+ Map<Path, Path> symLinks = resolveSymLinks(
|
|
|
|
+ container.getLocalizedResources(), container.getUser());
|
|
|
|
+
|
|
|
|
+ for (Map.Entry<Path, Path> symLink : symLinks.entrySet()) {
|
|
|
|
+ LOG.debug("{} deleting {}", container.getContainerId(),
|
|
|
|
+ symLink.getValue());
|
|
|
|
+ deleteAsUser(new DeletionAsUserContext.Builder()
|
|
|
|
+ .setUser(container.getUser())
|
|
|
|
+ .setSubDir(symLink.getValue())
|
|
|
|
+ .build());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Get the process-identifier for the container.
|
|
* Get the process-identifier for the container.
|
|
*
|
|
*
|
|
@@ -868,4 +881,25 @@ public abstract class ContainerExecutor implements Configurable {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private Map<Path, Path> resolveSymLinks(Map<Path,
|
|
|
|
+ List<String>> resources, String user) {
|
|
|
|
+ Map<Path, Path> symLinks = new HashMap<>();
|
|
|
|
+ for (Map.Entry<Path, List<String>> resourceEntry :
|
|
|
|
+ resources.entrySet()) {
|
|
|
|
+ for (String linkName : resourceEntry.getValue()) {
|
|
|
|
+ if (new Path(linkName).getName().equals(WILDCARD)) {
|
|
|
|
+ // If this is a wildcarded path, link to everything in the
|
|
|
|
+ // directory from the working directory
|
|
|
|
+ for (File wildLink : readDirAsUser(user, resourceEntry.getKey())) {
|
|
|
|
+ symLinks.put(new Path(wildLink.toString()),
|
|
|
|
+ new Path(wildLink.getName()));
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ symLinks.put(resourceEntry.getKey(), new Path(linkName));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return symLinks;
|
|
|
|
+ }
|
|
}
|
|
}
|