Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,10 @@ public class DFSConfigKeys extends CommonConfigurationKeys {
*/
public static final String DFS_NAMENODE_GETBLOCKS_MAX_QPS_KEY = "dfs.namenode.get-blocks.max-qps";
public static final int DFS_NAMENODE_GETBLOCKS_MAX_QPS_DEFAULT = 20;
public static final String DFS_NAMENODE_GETBLOCKS_CHECK_OPERATION_KEY
= "dfs.namenode.get-blocks.check.operation";
public static final boolean DFS_NAMENODE_GETBLOCKS_CHECK_OPERATION_DEFAULT
= true;

public static final String DFS_BALANCER_MOVEDWINWIDTH_KEY = "dfs.balancer.movedWinWidth";
public static final long DFS_BALANCER_MOVEDWINWIDTH_DEFAULT = 5400*1000L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,12 @@ private boolean isClientPortInfoAbsent(CallerContext ctx){
private final int snapshotDiffReportLimit;
private final int blockDeletionIncrement;

/**
* Whether enable checkOperation when call getBlocks.
* It is enabled by default.
*/
private final boolean isGetBlocksCheckOperationEnabled;

/** Interval between each check of lease to release. */
private final long leaseRecheckIntervalMs;
/** Maximum time the lock is hold to release lease. */
Expand Down Expand Up @@ -1066,6 +1072,10 @@ static FSNamesystem loadFromDisk(Configuration conf) throws IOException {
Preconditions.checkArgument(blockDeletionIncrement > 0,
DFSConfigKeys.DFS_NAMENODE_BLOCK_DELETION_INCREMENT_KEY +
" must be a positive integer.");
this.isGetBlocksCheckOperationEnabled = conf.getBoolean(
DFSConfigKeys.DFS_NAMENODE_GETBLOCKS_CHECK_OPERATION_KEY,
DFSConfigKeys.DFS_NAMENODE_GETBLOCKS_CHECK_OPERATION_DEFAULT);

} catch(IOException e) {
LOG.error(getClass().getSimpleName() + " initialization failed.", e);
close();
Expand Down Expand Up @@ -1938,10 +1948,13 @@ public boolean isInStandbyState() {
*/
public BlocksWithLocations getBlocks(DatanodeID datanode, long size, long
minimumBlockSize, long timeInterval) throws IOException {
checkOperation(OperationCategory.READ);
OperationCategory checkOp =
isGetBlocksCheckOperationEnabled ? OperationCategory.READ :
OperationCategory.UNCHECKED;
checkOperation(checkOp);
readLock();
try {
checkOperation(OperationCategory.READ);
checkOperation(checkOp);
return getBlockManager().getBlocksWithLocations(datanode, size,
minimumBlockSize, timeInterval);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4119,6 +4119,14 @@
Mover, and StoragePolicySatisfier.
</description>
</property>
<property>
<name>dfs.namenode.get-blocks.check.operation</name>
<value>true</value>
<description>
Whether enable checkOperation when call getBlocks.
It is enabled (true) by default.
Comment thread
Neilxzn marked this conversation as resolved.
Outdated
</description>
</property>
<property>
<name>dfs.balancer.dispatcherThreads</name>
<value>200</value>
Expand Down