HDFS-13271. WebHDFS: Add constructor in SnapshottableDirectoryStatus with HdfsFileStatus as argument. Contributed by Lokesh Jain
This commit is contained in:
parent
0355ec20eb
commit
b2b9ce5859
|
@ -50,32 +50,7 @@ public interface HdfsFileStatus
|
||||||
HAS_ACL,
|
HAS_ACL,
|
||||||
HAS_CRYPT,
|
HAS_CRYPT,
|
||||||
HAS_EC,
|
HAS_EC,
|
||||||
SNAPSHOT_ENABLED;
|
SNAPSHOT_ENABLED
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates an enum set of Flags from a set of attr flags.
|
|
||||||
* @param attr Set of attr flags
|
|
||||||
* @return EnumSet of Flags
|
|
||||||
*/
|
|
||||||
public static EnumSet<Flags> convert(Set<AttrFlags> attr) {
|
|
||||||
if (attr.isEmpty()) {
|
|
||||||
return EnumSet.noneOf(Flags.class);
|
|
||||||
}
|
|
||||||
EnumSet<Flags> flags = EnumSet.noneOf(Flags.class);
|
|
||||||
if (attr.contains(AttrFlags.HAS_ACL)) {
|
|
||||||
flags.add(Flags.HAS_ACL);
|
|
||||||
}
|
|
||||||
if (attr.contains(AttrFlags.HAS_EC)) {
|
|
||||||
flags.add(Flags.HAS_EC);
|
|
||||||
}
|
|
||||||
if (attr.contains(AttrFlags.HAS_CRYPT)) {
|
|
||||||
flags.add(Flags.HAS_CRYPT);
|
|
||||||
}
|
|
||||||
if (attr.contains(AttrFlags.SNAPSHOT_ENABLED)) {
|
|
||||||
flags.add(Flags.SNAPSHOT_ENABLED);
|
|
||||||
}
|
|
||||||
return flags;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -79,6 +79,14 @@ public class SnapshottableDirectoryStatus {
|
||||||
this.parentFullPath = parentFullPath;
|
this.parentFullPath = parentFullPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SnapshottableDirectoryStatus(HdfsFileStatus dirStatus,
|
||||||
|
int snapshotNumber, int snapshotQuota, byte[] parentFullPath) {
|
||||||
|
this.dirStatus = dirStatus;
|
||||||
|
this.snapshotNumber = snapshotNumber;
|
||||||
|
this.snapshotQuota = snapshotQuota;
|
||||||
|
this.parentFullPath = parentFullPath;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Number of snapshots that have been taken for the directory
|
* @return Number of snapshots that have been taken for the directory
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -65,7 +65,6 @@ import java.util.Collections;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
class JsonUtilClient {
|
class JsonUtilClient {
|
||||||
static final DatanodeInfo[] EMPTY_DATANODE_INFO_ARRAY = {};
|
static final DatanodeInfo[] EMPTY_DATANODE_INFO_ARRAY = {};
|
||||||
|
@ -772,15 +771,8 @@ class JsonUtilClient {
|
||||||
byte[] parentFullPath = toByteArray((String) json.get("parentFullPath"));
|
byte[] parentFullPath = toByteArray((String) json.get("parentFullPath"));
|
||||||
HdfsFileStatus dirStatus =
|
HdfsFileStatus dirStatus =
|
||||||
toFileStatus((Map<?, ?>) json.get("dirStatus"), false);
|
toFileStatus((Map<?, ?>) json.get("dirStatus"), false);
|
||||||
Set<FileStatus.AttrFlags> attrFlags = FileStatus
|
|
||||||
.attributes(dirStatus.hasAcl(), dirStatus.isEncrypted(),
|
|
||||||
dirStatus.isErasureCoded(), dirStatus.isSnapshotEnabled());
|
|
||||||
SnapshottableDirectoryStatus snapshottableDirectoryStatus =
|
SnapshottableDirectoryStatus snapshottableDirectoryStatus =
|
||||||
new SnapshottableDirectoryStatus(dirStatus.getModificationTime(),
|
new SnapshottableDirectoryStatus(dirStatus, snapshotNumber,
|
||||||
dirStatus.getAccessTime(), dirStatus.getPermission(),
|
|
||||||
HdfsFileStatus.Flags.convert(attrFlags), dirStatus.getOwner(),
|
|
||||||
dirStatus.getGroup(), dirStatus.getLocalNameInBytes(),
|
|
||||||
dirStatus.getFileId(), dirStatus.getChildrenNum(), snapshotNumber,
|
|
||||||
snapshotQuota, parentFullPath);
|
snapshotQuota, parentFullPath);
|
||||||
return snapshottableDirectoryStatus;
|
return snapshottableDirectoryStatus;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue