|
@@ -364,6 +364,9 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
|
|
|
|
private final long maxFsObjects; // maximum number of fs objects
|
|
private final long maxFsObjects; // maximum number of fs objects
|
|
|
|
|
|
|
|
+ private final long minBlockSize; // minimum block size
|
|
|
|
+ private final long maxBlocksPerFile; // maximum # of blocks per file
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* The global generation stamp for this file system.
|
|
* The global generation stamp for this file system.
|
|
*/
|
|
*/
|
|
@@ -595,6 +598,10 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
this.maxFsObjects = conf.getLong(DFS_NAMENODE_MAX_OBJECTS_KEY,
|
|
this.maxFsObjects = conf.getLong(DFS_NAMENODE_MAX_OBJECTS_KEY,
|
|
DFS_NAMENODE_MAX_OBJECTS_DEFAULT);
|
|
DFS_NAMENODE_MAX_OBJECTS_DEFAULT);
|
|
|
|
|
|
|
|
+ this.minBlockSize = conf.getLong(DFSConfigKeys.DFS_NAMENODE_MIN_BLOCK_SIZE_KEY,
|
|
|
|
+ DFSConfigKeys.DFS_NAMENODE_MIN_BLOCK_SIZE_DEFAULT);
|
|
|
|
+ this.maxBlocksPerFile = conf.getLong(DFSConfigKeys.DFS_NAMENODE_MAX_BLOCKS_PER_FILE_KEY,
|
|
|
|
+ DFSConfigKeys.DFS_NAMENODE_MAX_BLOCKS_PER_FILE_DEFAULT);
|
|
this.accessTimePrecision = conf.getLong(DFS_NAMENODE_ACCESSTIME_PRECISION_KEY,
|
|
this.accessTimePrecision = conf.getLong(DFS_NAMENODE_ACCESSTIME_PRECISION_KEY,
|
|
DFS_NAMENODE_ACCESSTIME_PRECISION_DEFAULT);
|
|
DFS_NAMENODE_ACCESSTIME_PRECISION_DEFAULT);
|
|
this.supportAppends = conf.getBoolean(DFS_SUPPORT_APPEND_KEY, DFS_SUPPORT_APPEND_DEFAULT);
|
|
this.supportAppends = conf.getBoolean(DFS_SUPPORT_APPEND_KEY, DFS_SUPPORT_APPEND_DEFAULT);
|
|
@@ -1818,6 +1825,11 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
final HdfsFileStatus stat;
|
|
final HdfsFileStatus stat;
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
FSPermissionChecker pc = getPermissionChecker();
|
|
checkOperation(OperationCategory.WRITE);
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
|
+ if (blockSize < minBlockSize) {
|
|
|
|
+ throw new IOException("Specified block size is less than configured" +
|
|
|
|
+ " minimum value (" + DFSConfigKeys.DFS_NAMENODE_MIN_BLOCK_SIZE_KEY
|
|
|
|
+ + "): " + blockSize + " < " + minBlockSize);
|
|
|
|
+ }
|
|
byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
|
|
byte[][] pathComponents = FSDirectory.getPathComponentsForReservedPath(src);
|
|
writeLock();
|
|
writeLock();
|
|
try {
|
|
try {
|
|
@@ -2245,7 +2257,12 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
|
// This is a retry. Just return the last block.
|
|
// This is a retry. Just return the last block.
|
|
return onRetryBlock[0];
|
|
return onRetryBlock[0];
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ if (pendingFile.getBlocks().length >= maxBlocksPerFile) {
|
|
|
|
+ throw new IOException("File has reached the limit on maximum number of"
|
|
|
|
+ + " blocks (" + DFSConfigKeys.DFS_NAMENODE_MAX_BLOCKS_PER_FILE_KEY
|
|
|
|
+ + "): " + pendingFile.getBlocks().length + " >= "
|
|
|
|
+ + maxBlocksPerFile);
|
|
|
|
+ }
|
|
blockSize = pendingFile.getPreferredBlockSize();
|
|
blockSize = pendingFile.getPreferredBlockSize();
|
|
clientNode = pendingFile.getClientNode();
|
|
clientNode = pendingFile.getClientNode();
|
|
replication = pendingFile.getBlockReplication();
|
|
replication = pendingFile.getBlockReplication();
|