|
@@ -53,6 +53,7 @@ import java.util.Arrays;
|
|
|
import java.util.Collection;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.Date;
|
|
|
+import java.util.EnumSet;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.LinkedHashSet;
|
|
|
import java.util.List;
|
|
@@ -83,6 +84,7 @@ import org.apache.hadoop.fs.FileSystem;
|
|
|
import org.apache.hadoop.fs.Path;
|
|
|
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
|
|
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants;
|
|
|
+import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
|
|
|
import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier;
|
|
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants;
|
|
|
import org.apache.hadoop.hdfs.server.common.Util;
|
|
@@ -1786,4 +1788,32 @@ public class DFSUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Generates HdfsFileStatus flags.
|
|
|
+ * @param isEncrypted Sets HAS_CRYPT
|
|
|
+ * @param isErasureCoded Sets HAS_EC
|
|
|
+ * @param isSnapShottable Sets SNAPSHOT_ENABLED
|
|
|
+ * @param hasAcl Sets HAS_ACL
|
|
|
+ * @return HdfsFileStatus Flags
|
|
|
+ */
|
|
|
+ public static EnumSet<HdfsFileStatus.Flags> getFlags(
|
|
|
+ final boolean isEncrypted, final boolean isErasureCoded,
|
|
|
+ boolean isSnapShottable, boolean hasAcl) {
|
|
|
+ EnumSet<HdfsFileStatus.Flags> flags =
|
|
|
+ EnumSet.noneOf(HdfsFileStatus.Flags.class);
|
|
|
+ if (hasAcl) {
|
|
|
+ flags.add(HdfsFileStatus.Flags.HAS_ACL);
|
|
|
+ }
|
|
|
+ if (isEncrypted) {
|
|
|
+ flags.add(HdfsFileStatus.Flags.HAS_CRYPT);
|
|
|
+ }
|
|
|
+ if (isErasureCoded) {
|
|
|
+ flags.add(HdfsFileStatus.Flags.HAS_EC);
|
|
|
+ }
|
|
|
+ if (isSnapShottable) {
|
|
|
+ flags.add(HdfsFileStatus.Flags.SNAPSHOT_ENABLED);
|
|
|
+ }
|
|
|
+ return flags;
|
|
|
+ }
|
|
|
+
|
|
|
}
|