|
@@ -60,6 +60,7 @@ import org.apache.hadoop.hdfs.DistributedFileSystem;
|
|
|
import org.apache.hadoop.hdfs.XAttrHelper;
|
|
|
import org.apache.hadoop.hdfs.protocol.AclException;
|
|
|
import org.apache.hadoop.hdfs.protocol.Block;
|
|
|
+import org.apache.hadoop.hdfs.protocol.BlockStoragePolicy;
|
|
|
import org.apache.hadoop.hdfs.protocol.ClientProtocol;
|
|
|
import org.apache.hadoop.hdfs.protocol.DirectoryListing;
|
|
|
import org.apache.hadoop.hdfs.protocol.EncryptionZone;
|
|
@@ -277,18 +278,18 @@ public class FSDirectory implements Closeable {
|
|
|
}
|
|
|
|
|
|
private static INodeFile newINodeFile(long id, PermissionStatus permissions,
|
|
|
- long mtime, long atime, short replication, long preferredBlockSize,
|
|
|
- boolean isLazyPersist) {
|
|
|
- return newINodeFile(id, permissions, mtime, atime, replication, preferredBlockSize,
|
|
|
- isLazyPersist, (byte)0);
|
|
|
+ long mtime, long atime, short replication, long preferredBlockSize) {
|
|
|
+ return new INodeFile(id, null, permissions, mtime, atime,
|
|
|
+ BlockInfo.EMPTY_ARRAY, replication, preferredBlockSize,
|
|
|
+ (byte) 0);
|
|
|
}
|
|
|
|
|
|
private static INodeFile newINodeFile(long id, PermissionStatus permissions,
|
|
|
long mtime, long atime, short replication, long preferredBlockSize,
|
|
|
- boolean isLazyPersist, byte storagePolicyId) {
|
|
|
+ byte storagePolicyId) {
|
|
|
return new INodeFile(id, null, permissions, mtime, atime,
|
|
|
BlockInfo.EMPTY_ARRAY, replication, preferredBlockSize,
|
|
|
- isLazyPersist, storagePolicyId);
|
|
|
+ storagePolicyId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -300,15 +301,13 @@ public class FSDirectory implements Closeable {
|
|
|
*/
|
|
|
INodeFile addFile(String path, PermissionStatus permissions,
|
|
|
short replication, long preferredBlockSize,
|
|
|
- boolean isLazyPersist,
|
|
|
String clientName, String clientMachine)
|
|
|
throws FileAlreadyExistsException, QuotaExceededException,
|
|
|
UnresolvedLinkException, SnapshotAccessControlException, AclException {
|
|
|
|
|
|
long modTime = now();
|
|
|
INodeFile newNode = newINodeFile(namesystem.allocateNewInodeId(),
|
|
|
- permissions, modTime, modTime, replication, preferredBlockSize,
|
|
|
- isLazyPersist);
|
|
|
+ permissions, modTime, modTime, replication, preferredBlockSize);
|
|
|
newNode.toUnderConstruction(clientName, clientMachine);
|
|
|
|
|
|
boolean added = false;
|
|
@@ -338,7 +337,6 @@ public class FSDirectory implements Closeable {
|
|
|
long modificationTime,
|
|
|
long atime,
|
|
|
long preferredBlockSize,
|
|
|
- boolean isLazyPersist,
|
|
|
boolean underConstruction,
|
|
|
String clientName,
|
|
|
String clientMachine,
|
|
@@ -347,12 +345,12 @@ public class FSDirectory implements Closeable {
|
|
|
assert hasWriteLock();
|
|
|
if (underConstruction) {
|
|
|
newNode = newINodeFile(id, permissions, modificationTime,
|
|
|
- modificationTime, replication, preferredBlockSize, isLazyPersist, storagePolicyId);
|
|
|
+ modificationTime, replication, preferredBlockSize, storagePolicyId);
|
|
|
newNode.toUnderConstruction(clientName, clientMachine);
|
|
|
|
|
|
} else {
|
|
|
newNode = newINodeFile(id, permissions, modificationTime, atime,
|
|
|
- replication, preferredBlockSize, isLazyPersist, storagePolicyId);
|
|
|
+ replication, preferredBlockSize, storagePolicyId);
|
|
|
}
|
|
|
|
|
|
try {
|
|
@@ -1040,6 +1038,20 @@ public class FSDirectory implements Closeable {
|
|
|
}
|
|
|
final int snapshotId = iip.getLatestSnapshotId();
|
|
|
if (inode.isFile()) {
|
|
|
+ BlockStoragePolicy newPolicy = getBlockManager().getStoragePolicy(policyId);
|
|
|
+ if (newPolicy.isCopyOnCreateFile()) {
|
|
|
+ throw new HadoopIllegalArgumentException(
|
|
|
+ "Policy " + newPolicy + " cannot be set after file creation.");
|
|
|
+ }
|
|
|
+
|
|
|
+ BlockStoragePolicy currentPolicy =
|
|
|
+ getBlockManager().getStoragePolicy(inode.getLocalStoragePolicyID());
|
|
|
+
|
|
|
+ if (currentPolicy != null && currentPolicy.isCopyOnCreateFile()) {
|
|
|
+ throw new HadoopIllegalArgumentException(
|
|
|
+ "Existing policy " + currentPolicy.getName() +
|
|
|
+ " cannot be changed after file creation.");
|
|
|
+ }
|
|
|
inode.asFile().setStoragePolicyID(policyId, snapshotId);
|
|
|
} else if (inode.isDirectory()) {
|
|
|
setDirStoragePolicy(inode.asDirectory(), policyId, snapshotId);
|
|
@@ -1546,7 +1558,7 @@ public class FSDirectory implements Closeable {
|
|
|
private HdfsFileStatus getFileInfo4DotSnapshot(String src)
|
|
|
throws UnresolvedLinkException {
|
|
|
if (getINode4DotSnapshot(src) != null) {
|
|
|
- return new HdfsFileStatus(0, true, 0, 0, false, 0, 0, null, null, null, null,
|
|
|
+ return new HdfsFileStatus(0, true, 0, 0, 0, 0, null, null, null, null,
|
|
|
HdfsFileStatus.EMPTY_NAME, -1L, 0, null,
|
|
|
BlockStoragePolicySuite.ID_UNSPECIFIED);
|
|
|
}
|
|
@@ -2406,7 +2418,6 @@ public class FSDirectory implements Closeable {
|
|
|
long size = 0; // length is zero for directories
|
|
|
short replication = 0;
|
|
|
long blocksize = 0;
|
|
|
- boolean isLazyPersist = false;
|
|
|
final boolean isEncrypted;
|
|
|
|
|
|
final FileEncryptionInfo feInfo = isRawPath ? null :
|
|
@@ -2417,7 +2428,6 @@ public class FSDirectory implements Closeable {
|
|
|
size = fileNode.computeFileSize(snapshot);
|
|
|
replication = fileNode.getFileReplication(snapshot);
|
|
|
blocksize = fileNode.getPreferredBlockSize();
|
|
|
- isLazyPersist = fileNode.getLazyPersistFlag();
|
|
|
isEncrypted = (feInfo != null) ||
|
|
|
(isRawPath && isInAnEZ(INodesInPath.fromINode(node)));
|
|
|
} else {
|
|
@@ -2432,7 +2442,6 @@ public class FSDirectory implements Closeable {
|
|
|
node.isDirectory(),
|
|
|
replication,
|
|
|
blocksize,
|
|
|
- isLazyPersist,
|
|
|
node.getModificationTime(snapshot),
|
|
|
node.getAccessTime(snapshot),
|
|
|
getPermissionForFileStatus(node, snapshot, isEncrypted),
|
|
@@ -2456,7 +2465,6 @@ public class FSDirectory implements Closeable {
|
|
|
long size = 0; // length is zero for directories
|
|
|
short replication = 0;
|
|
|
long blocksize = 0;
|
|
|
- boolean isLazyPersist = false;
|
|
|
LocatedBlocks loc = null;
|
|
|
final boolean isEncrypted;
|
|
|
final FileEncryptionInfo feInfo = isRawPath ? null :
|
|
@@ -2466,7 +2474,6 @@ public class FSDirectory implements Closeable {
|
|
|
size = fileNode.computeFileSize(snapshot);
|
|
|
replication = fileNode.getFileReplication(snapshot);
|
|
|
blocksize = fileNode.getPreferredBlockSize();
|
|
|
- isLazyPersist = fileNode.getLazyPersistFlag();
|
|
|
|
|
|
final boolean inSnapshot = snapshot != Snapshot.CURRENT_STATE_ID;
|
|
|
final boolean isUc = !inSnapshot && fileNode.isUnderConstruction();
|
|
@@ -2489,7 +2496,7 @@ public class FSDirectory implements Closeable {
|
|
|
|
|
|
HdfsLocatedFileStatus status =
|
|
|
new HdfsLocatedFileStatus(size, node.isDirectory(), replication,
|
|
|
- blocksize, isLazyPersist, node.getModificationTime(snapshot),
|
|
|
+ blocksize, node.getModificationTime(snapshot),
|
|
|
node.getAccessTime(snapshot),
|
|
|
getPermissionForFileStatus(node, snapshot, isEncrypted),
|
|
|
node.getUserName(snapshot), node.getGroupName(snapshot),
|