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 67A3C200C5C for ; Thu, 6 Apr 2017 03:35:50 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 6633A160B9E; Thu, 6 Apr 2017 01:35:50 +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 5FCAF160B94 for ; Thu, 6 Apr 2017 03:35:49 +0200 (CEST) Received: (qmail 80757 invoked by uid 500); 6 Apr 2017 01:35:48 -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 80735 invoked by uid 99); 6 Apr 2017 01:35:47 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Apr 2017 01:35:47 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id F0899C04DE for ; Thu, 6 Apr 2017 01:35:45 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-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 (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id iuFoWgQywGxF for ; Thu, 6 Apr 2017 01:35:43 +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 C84395F24E for ; Thu, 6 Apr 2017 01:35: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 00F8DE08BB for ; Thu, 6 Apr 2017 01:35:41 +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 91F87263C7 for ; Thu, 6 Apr 2017 01:35:41 +0000 (UTC) Date: Thu, 6 Apr 2017 01:35: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:35:50 -0000 [ https://issues.apache.org/jira/browse/HBASE-16469?page=3Dcom.atlassi= an.jira.plugin.system.issuetabpanels:all-tabpanel ] Nemo Chen updated HBASE-16469: ------------------------------ Description:=20 *method invocation replaced by variable* hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/Clo= seRegionHandler.java line 118: {code}String name =3D regionInfo.getRegionNameAsString();{code} line 142: {code}LOG.warn("Can't close region: was already closed during clo= se(): " + regionInfo.getRegionNameAsString()); {code} In the above two examples, the method invocations are assigned to the varia= bles before the logging code. These method invocations should be replaced b= y variables in case of simplicity and readability ---- *method invocation in return statement* hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.jav= a 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().getRegionNameAsStri= ng()); {code} In these above examples, the "getRegionInfo().getRegionNameAsString())" is = 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 readabili= ty. ---- *check the logged variable if it is null* hbase-it/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.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-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager= .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-server/src/test/java/org/apache/hadoop/hbase/util/MultiThreadedUpdate= r.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* 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/PreemptiveFastFai= lInterceptor.java {code} LOG.info("Clearing out PFFE for server " + server.getServerName()); return getServerName(); {code} was: *method invocation replaced by variable* hbase-1.2.2/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver= /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 clo= se(): " + regionInfo.getRegionNameAsString()); {code} In the above two examples, the method invocations are assigned to the varia= bles before the logging code. These method invocations should be replaced b= y 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/regionserver= /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().getRegionNameAsStri= ng()); {code} In these above examples, the "getRegionInfo().getRegionNameAsString())" is = 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 readabili= ty. ---- *check the logged variable if it is null* hbase-1.2.2/hbase-it/src/test/java/org/apache/hadoop/hbase/HBaseClusterMana= ger.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/Assig= nmentManager.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/MultiTh= readedUpdater.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/Async= Process.java {code} LOG.warn("#" + id + ", the task was rejected by the pool. This is unexpecte= d."+ " 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/Preem= ptiveFastFailInterceptor.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/RpcServe= r.java line 705:=20 {code} LOG.debug(getName() + ": disconnecting client " + c.getHostAddress()= ); {code} line 1259: {code}=20 public String toString() { return getHostAddress() + ":" + remotePort; } {code} > 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 > > 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 > 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-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.j= ava > 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-it/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.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-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManag= er.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-server/src/test/java/org/apache/hadoop/hbase/util/MultiThreadedUpda= ter.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* > 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)