HDFS-2541. For a sufficiently large value of blocks, the DN Scanner may request a random number with a negative seed value. Contributed by Harsh J

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1204114 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Eli Collins 2011-11-20 02:51:50 +00:00
parent b7cd8c0f86
commit 7a8015c0e2
2 changed files with 5 additions and 2 deletions

View File

@ -133,6 +133,9 @@ Release 0.23.1 - UNRELEASED
BUG FIXES BUG FIXES
HDFS-2541. For a sufficiently large value of blocks, the DN Scanner
may request a random number with a negative seed value. (harsh)
Release 0.23.0 - 2011-11-01 Release 0.23.0 - 2011-11-01
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -34,7 +34,6 @@
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Random;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -252,8 +251,9 @@ private synchronized long getNewBlockScanTime() {
*/ */
long period = Math.min(scanPeriod, long period = Math.min(scanPeriod,
Math.max(blockMap.size(),1) * 600 * 1000L); Math.max(blockMap.size(),1) * 600 * 1000L);
int periodInt = Math.abs((int)period);
return System.currentTimeMillis() - scanPeriod + return System.currentTimeMillis() - scanPeriod +
DFSUtil.getRandom().nextInt((int)period); DFSUtil.getRandom().nextInt(periodInt);
} }
/** Adds block to list of blocks */ /** Adds block to list of blocks */