Return-Path: X-Original-To: apmail-hbase-issues-archive@www.apache.org Delivered-To: apmail-hbase-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0F03310C7E for ; Tue, 18 Feb 2014 22:53:47 +0000 (UTC) Received: (qmail 76419 invoked by uid 500); 18 Feb 2014 22:53:26 -0000 Delivered-To: apmail-hbase-issues-archive@hbase.apache.org Received: (qmail 76268 invoked by uid 500); 18 Feb 2014 22:53:25 -0000 Mailing-List: contact issues-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@hbase.apache.org Received: (qmail 76130 invoked by uid 99); 18 Feb 2014 22:53:23 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Feb 2014 22:53:23 +0000 Date: Tue, 18 Feb 2014 22:53:23 +0000 (UTC) From: "Hudson (JIRA)" To: issues@hbase.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HBASE-10564) HRegionServer.nextLong should be removed since it's not used anywhere, or should be used somewhere it meant to MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HBASE-10564?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13904745#comment-13904745 ] Hudson commented on HBASE-10564: -------------------------------- SUCCESS: Integrated in HBase-0.98 #165 (See [https://builds.apache.org/job/HBase-0.98/165/]) HBASE-10564 HRegionServer.nextLong should be removed (Feng Honghua) (apurtell: rev 1569476) * /hbase/branches/0.98/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)