HDFS-3819. Should check whether invalidate work percentage default value is not greater than 1.0f. Contributed by Jing Zhao.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1376185 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
30bd8ef9d1
commit
901b1739c6
@ -123,6 +123,9 @@ Trunk (unreleased changes)
|
|||||||
HDFS-3817. Avoid printing SafeModeException stack trace.
|
HDFS-3817. Avoid printing SafeModeException stack trace.
|
||||||
(Brandon Li via suresh)
|
(Brandon Li via suresh)
|
||||||
|
|
||||||
|
HDFS-3819. Should check whether invalidate work percentage default value is
|
||||||
|
not greater than 1.0f. (Jing Zhao via jitendra)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
@ -1156,11 +1156,11 @@ public static float getInvalidateWorkPctPerIteration(Configuration conf) {
|
|||||||
DFSConfigKeys.DFS_NAMENODE_INVALIDATE_WORK_PCT_PER_ITERATION,
|
DFSConfigKeys.DFS_NAMENODE_INVALIDATE_WORK_PCT_PER_ITERATION,
|
||||||
DFSConfigKeys.DFS_NAMENODE_INVALIDATE_WORK_PCT_PER_ITERATION_DEFAULT);
|
DFSConfigKeys.DFS_NAMENODE_INVALIDATE_WORK_PCT_PER_ITERATION_DEFAULT);
|
||||||
Preconditions.checkArgument(
|
Preconditions.checkArgument(
|
||||||
(blocksInvalidateWorkPct > 0),
|
(blocksInvalidateWorkPct > 0 && blocksInvalidateWorkPct <= 1.0f),
|
||||||
DFSConfigKeys.DFS_NAMENODE_INVALIDATE_WORK_PCT_PER_ITERATION +
|
DFSConfigKeys.DFS_NAMENODE_INVALIDATE_WORK_PCT_PER_ITERATION +
|
||||||
" = '" + blocksInvalidateWorkPct + "' is invalid. " +
|
" = '" + blocksInvalidateWorkPct + "' is invalid. " +
|
||||||
"It should be a positive, non-zero float value " +
|
"It should be a positive, non-zero float value, not greater than 1.0f, " +
|
||||||
"indicating a percentage.");
|
"to indicate a percentage.");
|
||||||
return blocksInvalidateWorkPct;
|
return blocksInvalidateWorkPct;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -645,7 +645,7 @@ public void testChooseReplicaToDelete() throws Exception {
|
|||||||
* This testcase tests whether the default value returned by
|
* This testcase tests whether the default value returned by
|
||||||
* DFSUtil.getInvalidateWorkPctPerIteration() is positive,
|
* DFSUtil.getInvalidateWorkPctPerIteration() is positive,
|
||||||
* and whether an IllegalArgumentException will be thrown
|
* and whether an IllegalArgumentException will be thrown
|
||||||
* when a non-positive value is retrieved
|
* when 0.0f is retrieved
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetInvalidateWorkPctPerIteration() {
|
public void testGetInvalidateWorkPctPerIteration() {
|
||||||
@ -660,7 +660,48 @@ public void testGetInvalidateWorkPctPerIteration() {
|
|||||||
assertEquals(blocksInvalidateWorkPct, 0.5f, blocksInvalidateWorkPct * 1e-7);
|
assertEquals(blocksInvalidateWorkPct, 0.5f, blocksInvalidateWorkPct * 1e-7);
|
||||||
|
|
||||||
conf.set(DFSConfigKeys.
|
conf.set(DFSConfigKeys.
|
||||||
DFS_NAMENODE_INVALIDATE_WORK_PCT_PER_ITERATION, "0.0");
|
DFS_NAMENODE_INVALIDATE_WORK_PCT_PER_ITERATION, "1.0f");
|
||||||
|
blocksInvalidateWorkPct = DFSUtil.getInvalidateWorkPctPerIteration(conf);
|
||||||
|
assertEquals(blocksInvalidateWorkPct, 1.0f, blocksInvalidateWorkPct * 1e-7);
|
||||||
|
|
||||||
|
conf.set(DFSConfigKeys.
|
||||||
|
DFS_NAMENODE_INVALIDATE_WORK_PCT_PER_ITERATION, "0.0f");
|
||||||
|
exception.expect(IllegalArgumentException.class);
|
||||||
|
blocksInvalidateWorkPct = DFSUtil.getInvalidateWorkPctPerIteration(conf);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This testcase tests whether an IllegalArgumentException
|
||||||
|
* will be thrown when a negative value is retrieved by
|
||||||
|
* DFSUtil#getInvalidateWorkPctPerIteration
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetInvalidateWorkPctPerIteration_NegativeValue() {
|
||||||
|
Configuration conf = new Configuration();
|
||||||
|
float blocksInvalidateWorkPct = DFSUtil
|
||||||
|
.getInvalidateWorkPctPerIteration(conf);
|
||||||
|
assertTrue(blocksInvalidateWorkPct > 0);
|
||||||
|
|
||||||
|
conf.set(DFSConfigKeys.
|
||||||
|
DFS_NAMENODE_INVALIDATE_WORK_PCT_PER_ITERATION, "-0.5f");
|
||||||
|
exception.expect(IllegalArgumentException.class);
|
||||||
|
blocksInvalidateWorkPct = DFSUtil.getInvalidateWorkPctPerIteration(conf);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This testcase tests whether an IllegalArgumentException
|
||||||
|
* will be thrown when a value greater than 1 is retrieved by
|
||||||
|
* DFSUtil#getInvalidateWorkPctPerIteration
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGetInvalidateWorkPctPerIteration_GreaterThanOne() {
|
||||||
|
Configuration conf = new Configuration();
|
||||||
|
float blocksInvalidateWorkPct = DFSUtil
|
||||||
|
.getInvalidateWorkPctPerIteration(conf);
|
||||||
|
assertTrue(blocksInvalidateWorkPct > 0);
|
||||||
|
|
||||||
|
conf.set(DFSConfigKeys.
|
||||||
|
DFS_NAMENODE_INVALIDATE_WORK_PCT_PER_ITERATION, "1.5f");
|
||||||
exception.expect(IllegalArgumentException.class);
|
exception.expect(IllegalArgumentException.class);
|
||||||
blocksInvalidateWorkPct = DFSUtil.getInvalidateWorkPctPerIteration(conf);
|
blocksInvalidateWorkPct = DFSUtil.getInvalidateWorkPctPerIteration(conf);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user