[ 
https://issues.apache.org/jira/browse/HBASE-10564?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13905029#comment-13905029
 ] 

Hudson commented on HBASE-10564:
--------------------------------

FAILURE: Integrated in HBase-TRUNK-on-Hadoop-1.1 #93 (See 
[https://builds.apache.org/job/HBase-TRUNK-on-Hadoop-1.1/93/])
HBASE-10564 HRegionServer.nextLong should be removed since it's not used 
anywhere, or should be used somewhere it meant to (stack: rev 1569467)
* 
/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java


> HRegionServer.nextLong should be removed since it's not used anywhere, or 
> should be used somewhere it meant to
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-10564
>                 URL: https://issues.apache.org/jira/browse/HBASE-10564
>             Project: HBase
>          Issue Type: Bug
>          Components: regionserver
>            Reporter: Feng Honghua
>            Assignee: Feng Honghua
>            Priority: Minor
>             Fix For: 0.98.1, 0.99.0
>
>         Attachments: HBASE-10564-trunk_v1.patch
>
>
> HRegionServer has its own nextLong method as below:
> {code}
>   /**
>    * Generate a random positive long number
>    *
>    * @return a random positive long number
>    */
>   protected long nextLong() {
>     long n = rand.nextLong();
>     if (n == 0) {
>       return nextLong();
>     }
>     if (n < 0) {
>       n = -n;
>     }
>     return n;
>   }
> {code}
> # It's never called anywhere, if we can ensure it's really useless, it should 
> be removed
> # Looks likely below should use *nextLong* rather than *rand.nextLong*(but 
> not sure):
> {code}
>   protected long addScanner(RegionScanner s, HRegion r) throws 
> LeaseStillHeldException {
>     long scannerId = -1;
>     while (true) {
>       scannerId = Math.abs(rand.nextLong() << 24) ^ startcode;
>       String scannerName = String.valueOf(scannerId);
>       RegionScannerHolder existing =
>         scanners.putIfAbsent(scannerName, new RegionScannerHolder(s, r));
>       if (existing == null) {
>         this.leases.createLease(scannerName, this.scannerLeaseTimeoutPeriod,
>           new ScannerListener(scannerName));
>         break;
>       }
>     }
>     return scannerId;
>   }
> {code}
> # Its implemenation would be better if
> {code}
>     if (n == 0) {
>       return nextLong();
>     }
> {code}
> is changed to below (with better readability and (possible) less call-stacks 
> by removing recursion)
> {code}
>     while (n == 0) {
>       n = rand.nextLong();
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to