Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 0C9E2200C53 for ; Tue, 11 Apr 2017 22:14:47 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0B322160B9B; Tue, 11 Apr 2017 20:14:47 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5147D160B7D for ; Tue, 11 Apr 2017 22:14:46 +0200 (CEST) Received: (qmail 33977 invoked by uid 500); 11 Apr 2017 20:14:45 -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 33965 invoked by uid 99); 11 Apr 2017 20:14:45 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Apr 2017 20:14:45 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 06A75C12B0 for ; Tue, 11 Apr 2017 20:14:45 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.002 X-Spam-Level: X-Spam-Status: No, score=-100.002 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id TBhLK0lSpCLw for ; Tue, 11 Apr 2017 20:14:44 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 5853D60DF7 for ; Tue, 11 Apr 2017 20:14:43 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 72C30E0A6C for ; Tue, 11 Apr 2017 20:14:42 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id D02A024067 for ; Tue, 11 Apr 2017 20:14:41 +0000 (UTC) Date: Tue, 11 Apr 2017 20:14:41 +0000 (UTC) From: "Sean Busbey (JIRA)" To: issues@hbase.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HBASE-16469) Several log refactoring/improvement suggestions MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 11 Apr 2017 20:14:47 -0000 [ https://issues.apache.org/jira/browse/HBASE-16469?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D159= 64898#comment-15964898 ]=20 Sean Busbey commented on HBASE-16469: ------------------------------------- Pushed to master and branch-1. Thanks for the contribution [~chenfsd]! One thing for next time, please leave patches attached to the issue and jus= t increment the patch number as you update things (e.g. HBASE-16469.master.= 002.patch, etc). It makes it much easier to both see how things have evolve= d and figure out if earlier feedback is still relevant. > Several log refactoring/improvement suggestions > ----------------------------------------------- > > Key: HBASE-16469 > URL: https://issues.apache.org/jira/browse/HBASE-16469 > Project: HBase > Issue Type: Improvement > Components: Operability > Affects Versions: 1.2.5 > Reporter: Nemo Chen > Assignee: Nemo Chen > Labels: easyfix, easytest > Fix For: 2.0.0, 1.4.0 > > Attachments: HBASE-16469.master.001.patch > > > *method invocation replaced by variable* > hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/C= loseRegionHandler.java > {code}String name =3D regionInfo.getRegionNameAsString();{code} > {code}LOG.warn("Can't close region: was already closed during close(): " = + > regionInfo.getRegionNameAsString()); {code} > In the above two examples, the method invocations are assigned to the var= iables before the logging code. These method invocations should be replaced= by variables in case of simplicity and readability > ---- > *method invocation in return statement* > hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.j= ava > {code} > public String toString() { > return getRegionInfo().getRegionNameAsString(); > } > {code} > {code} > LOG.debug("Region " + getRegionInfo().getRegionNameAsString() > + " is not mergeable because it is closing or closed"); > {code} > {code} > LOG.debug("Region " + getRegionInfo().getRegionNameAsString() > + " is not mergeable because it has references"); > {code} > {code}=20 > LOG.info("Running close preflush of " + getRegionInfo().getRegionNameAsSt= ring()); > {code} > In these above examples, the "getRegionInfo().getRegionNameAsString())" i= s the return statement of method "toString" in the same class. They should = be replaced with =E2=80=9Cthis=E2=80=9D in case of simplicity and readabi= lity. > ---- > *check the logged variable if it is null* > hbase-it/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.java > {code} > if ((sshUserName !=3D null && sshUserName.length() > 0) || > (sshOptions !=3D null && sshOptions.length() > 0)) { > LOG.info("Running with SSH user [" + sshUserName + "] and options [= " + sshOptions + "]"); > } > {code} > hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManag= er.java > {code} > if ((regionState =3D=3D null && latestState !=3D null) > || (regionState !=3D null && latestState =3D=3D null) > || (regionState !=3D null && latestState !=3D null > && latestState.getState() !=3D regionState.getState())) { > LOG.warn("Region state changed from " + regionState + " to " > + latestState + ", while acquiring lock"); > } > {code} > In the above example, the logging variable could null at run time. It is = a bad practice to include null variables inside logs. > ---- > *variable in byte printed directly* > hbase-server/src/test/java/org/apache/hadoop/hbase/util/MultiThreadedUpda= ter.java > {code} > byte[] rowKey =3D dataGenerator.getDeterministicUniqueKey(rowKeyBase); > {code} > {code} > LOG.error("Failed to update the row with key =3D [" + rowKey > + "], since we could not get the original row"); > {code} > rowKey should be printed as Bytes.toString(rowKey). > ----=20 > *object toString contain mi* > The toString method returns getServerName(), so the "server.getServerName= ()" should be replaced with "server" in case of simplicity and readability. > hbase-client/src/main/java/org/apache/hadoop/hbase/client/PreemptiveFastF= ailInterceptor.java > {code} > LOG.info("Clearing out PFFE for server " + server.getServerName()); > return getServerName(); > {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)