|
@@ -20,6 +20,7 @@ package org.apache.hadoop.test.system;
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.security.PrivilegedExceptionAction;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
@@ -28,6 +29,7 @@ import java.util.Properties;
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.LogFactory;
|
|
import org.apache.commons.logging.LogFactory;
|
|
import org.apache.hadoop.io.Writable;
|
|
import org.apache.hadoop.io.Writable;
|
|
|
|
+import org.apache.hadoop.security.UserGroupInformation;
|
|
import org.apache.hadoop.util.Shell.ShellCommandExecutor;
|
|
import org.apache.hadoop.util.Shell.ShellCommandExecutor;
|
|
import org.apache.hadoop.fs.FileStatus;
|
|
import org.apache.hadoop.fs.FileStatus;
|
|
import org.apache.hadoop.fs.FileSystem;
|
|
import org.apache.hadoop.fs.FileSystem;
|
|
@@ -157,18 +159,27 @@ public aspect DaemonProtocolAspect {
|
|
fileStatus.getPath());
|
|
fileStatus.getPath());
|
|
}
|
|
}
|
|
|
|
|
|
- private FileSystem DaemonProtocol.getFS(Path path, boolean local)
|
|
|
|
- throws IOException {
|
|
|
|
- FileSystem fs = null;
|
|
|
|
- if (local) {
|
|
|
|
- fs = FileSystem.getLocal(getDaemonConf());
|
|
|
|
- } else {
|
|
|
|
- fs = path.getFileSystem(getDaemonConf());
|
|
|
|
|
|
+ private FileSystem DaemonProtocol.getFS(final Path path, final boolean local)
|
|
|
|
+ throws IOException {
|
|
|
|
+ FileSystem ret = null;
|
|
|
|
+ try {
|
|
|
|
+ ret = UserGroupInformation.getLoginUser().doAs (
|
|
|
|
+ new PrivilegedExceptionAction<FileSystem>() {
|
|
|
|
+ public FileSystem run() throws IOException {
|
|
|
|
+ FileSystem fs = null;
|
|
|
|
+ if (local) {
|
|
|
|
+ fs = FileSystem.getLocal(getDaemonConf());
|
|
|
|
+ } else {
|
|
|
|
+ fs = path.getFileSystem(getDaemonConf());
|
|
|
|
+ }
|
|
|
|
+ return fs;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ } catch (InterruptedException ie) {
|
|
}
|
|
}
|
|
- return fs;
|
|
|
|
|
|
+ return ret;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@SuppressWarnings("unchecked")
|
|
public ControlAction[] DaemonProtocol.getActions(Writable key)
|
|
public ControlAction[] DaemonProtocol.getActions(Writable key)
|
|
throws IOException {
|
|
throws IOException {
|