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 8C05C200C5C for ; Thu, 6 Apr 2017 03:22:46 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 8A81D160B9E; Thu, 6 Apr 2017 01:22:46 +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 AAD2F160B94 for ; Thu, 6 Apr 2017 03:22:45 +0200 (CEST) Received: (qmail 64671 invoked by uid 500); 6 Apr 2017 01:22:44 -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 64384 invoked by uid 99); 6 Apr 2017 01:22:44 -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; Thu, 06 Apr 2017 01:22:44 +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 0BB53C090C for ; Thu, 6 Apr 2017 01:22:44 +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-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id csxeheMzGU2w for ; Thu, 6 Apr 2017 01:22:43 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id EEFE85FBC1 for ; Thu, 6 Apr 2017 01:22:42 +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 41B02E0B08 for ; Thu, 6 Apr 2017 01:22: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 9765E263C8 for ; Thu, 6 Apr 2017 01:22:41 +0000 (UTC) Date: Thu, 6 Apr 2017 01:22:41 +0000 (UTC) From: "Nemo Chen (JIRA)" To: issues@hbase.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (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: Thu, 06 Apr 2017 01:22:46 -0000 [ https://issues.apache.org/jira/browse/HBASE-16469?page=3Dcom.atlassi= an.jira.plugin.system.issuetabpanels:all-tabpanel ] Nemo Chen updated HBASE-16469: ------------------------------ Attachment: (was: HBASE-16469.master.001.patch) > 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.5.0 > > > *method invocation replaced by variable* > hbase-1.2.2/hbase-server/src/main/java/org/apache/hadoop/hbase/backup/exa= mple/LongTermArchivingHFileCleaner.java > line 57: {code}Path file =3D fStat.getPath();{code} > line 74: {code}LOG.error("Failed to lookup status of:" + fStat.getPath() = + ", keeping it just incase.", e); {code} > hbase-1.2.2/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserv= er/handler/CloseRegionHandler.java > line 118: {code}String name =3D regionInfo.getRegionNameAsString();{code} > line 142: {code}LOG.warn("Can't close region: was already closed during c= lose(): " + > 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-1.2.2/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserv= er/HRegion.java > line 5455: > {code} > public String toString() { > return getRegionInfo().getRegionNameAsString(); > } > {code} > line 1260: > {code} > LOG.debug("Region " + getRegionInfo().getRegionNameAsString() > + " is not mergeable because it is closing or closed"); > {code} > line 1265: > {code} > LOG.debug("Region " + getRegionInfo().getRegionNameAsString() > + " is not mergeable because it has references"); > {code} > line 1413: > {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-1.2.2/hbase-it/src/test/java/org/apache/hadoop/hbase/HBaseClusterMa= nager.java > line 88:=20 > {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-1.2.2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/Ass= ignmentManager.java > line 980: > {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-1.2.2/hbase-server/src/test/java/org/apache/hadoop/hbase/util/Multi= ThreadedUpdater.java > line 145:=20 > {code} > byte[] rowKey =3D dataGenerator.getDeterministicUniqueKey(rowKeyBase); > {code} > line 184: > {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* > hbase-1.2.2/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Asy= ncProcess.java > {code} > LOG.warn("#" + id + ", the task was rejected by the pool. This is unexpec= ted."+ " Server is "+ server.getServerName(),t); > {code} > server is an instance of class ServerName, we found ServerName.java: > hbase-client/src/main/java/org/apache/hadoop/hbase/ServerName.java > {code} > @Override > public String toString() { > return getServerName(); > } > {code} > the toString method returns getServerName(), so the "server.getServerName= ()" should be replaced with "server" in case of simplicity and readability > Similar examples are in: > hbase-1.2.2/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Pre= emptiveFastFailInterceptor.java > {code} > LOG.info("Clearing out PFFE for server " + server.getServerName()); > return getServerName(); > {code} > hbase-1.2.2/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcSer= ver.java > line 705:=20 > {code} LOG.debug(getName() + ": disconnecting client " + c.getHostAddress= ()); {code} > line 1259: > {code}=20 > public String toString() { > return getHostAddress() + ":" + remotePort; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)