|
@@ -30,9 +30,7 @@ import org.apache.hadoop.conf.Configuration;
|
|
|
import org.apache.hadoop.crypto.key.KeyProvider;
|
|
|
import org.apache.hadoop.fs.BlockStoragePolicySpi;
|
|
|
import org.apache.hadoop.fs.CacheFlag;
|
|
|
-import org.apache.hadoop.fs.FileAlreadyExistsException;
|
|
|
import org.apache.hadoop.fs.FileEncryptionInfo;
|
|
|
-import org.apache.hadoop.fs.FileStatus;
|
|
|
import org.apache.hadoop.fs.FileSystem;
|
|
|
import org.apache.hadoop.fs.Path;
|
|
|
import org.apache.hadoop.fs.RemoteIterator;
|
|
@@ -324,7 +322,7 @@ public class HdfsAdmin {
|
|
|
throw new HadoopIllegalArgumentException(
|
|
|
"can not have both PROVISION_TRASH and NO_TRASH flags");
|
|
|
}
|
|
|
- this.provisionEZTrash(path);
|
|
|
+ dfs.provisionEZTrash(path, TRASH_PERMISSION);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -335,7 +333,7 @@ public class HdfsAdmin {
|
|
|
* @throws IOException if the trash directory can not be created.
|
|
|
*/
|
|
|
public void provisionEncryptionZoneTrash(Path path) throws IOException {
|
|
|
- this.provisionEZTrash(path);
|
|
|
+ dfs.provisionEZTrash(path, TRASH_PERMISSION);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -473,46 +471,6 @@ public class HdfsAdmin {
|
|
|
return dfs.getAllStoragePolicies();
|
|
|
}
|
|
|
|
|
|
- private void provisionEZTrash(Path path) throws IOException {
|
|
|
- // make sure the path is an EZ
|
|
|
- EncryptionZone ez = dfs.getEZForPath(path);
|
|
|
- if (ez == null) {
|
|
|
- throw new IllegalArgumentException(path + " is not an encryption zone.");
|
|
|
- }
|
|
|
-
|
|
|
- String ezPath = ez.getPath();
|
|
|
- if (!path.toString().equals(ezPath)) {
|
|
|
- throw new IllegalArgumentException(path + " is not the root of an " +
|
|
|
- "encryption zone. Do you mean " + ez.getPath() + "?");
|
|
|
- }
|
|
|
-
|
|
|
- // check if the trash directory exists
|
|
|
-
|
|
|
- Path trashPath = new Path(ez.getPath(), FileSystem.TRASH_PREFIX);
|
|
|
-
|
|
|
- try {
|
|
|
- FileStatus trashFileStatus = dfs.getFileStatus(trashPath);
|
|
|
- String errMessage = "Will not provision new trash directory for " +
|
|
|
- "encryption zone " + ez.getPath() + ". Path already exists.";
|
|
|
- if (!trashFileStatus.isDirectory()) {
|
|
|
- errMessage += "\r\n" +
|
|
|
- "Warning: " + trashPath.toString() + " is not a directory";
|
|
|
- }
|
|
|
- if (!trashFileStatus.getPermission().equals(TRASH_PERMISSION)) {
|
|
|
- errMessage += "\r\n" +
|
|
|
- "Warning: the permission of " +
|
|
|
- trashPath.toString() + " is not " + TRASH_PERMISSION;
|
|
|
- }
|
|
|
- throw new FileAlreadyExistsException(errMessage);
|
|
|
- } catch (FileNotFoundException ignored) {
|
|
|
- // no trash path
|
|
|
- }
|
|
|
-
|
|
|
- // Update the permission bits
|
|
|
- dfs.mkdir(trashPath, TRASH_PERMISSION);
|
|
|
- dfs.setPermission(trashPath, TRASH_PERMISSION);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Returns a RemoteIterator which can be used to list all open files
|
|
|
* currently managed by the NameNode. For large numbers of open files,
|