You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@zookeeper.apache.org by "Chen Zhi (Jira)" <ji...@apache.org> on 2019/10/28 14:24:00 UTC

[jira] [Commented] (ZOOKEEPER-3487) Execution the same conditional statement twice in ZooTrace

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

Chen Zhi commented on ZOOKEEPER-3487:
-------------------------------------

`logTraceMessage(Logger log, long mask, String msg)` is a general util function to log trace message. The logging guard inside `logTraceMessage` is used to filter log messages with lower priority.  `logQuorumPacket(Logger log, long mask, char direction, QuorumPacket qp)` is a util function to log Quorum Packet. The logging guard inside `logQuorumPacket` is necessary to skip the function call of `LearnerHandler.packetToString(qp)`, which is an expensive operation.

> Execution the same conditional statement twice in ZooTrace
> ----------------------------------------------------------
>
>                 Key: ZOOKEEPER-3487
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-3487
>             Project: ZooKeeper
>          Issue Type: Improvement
>          Components: server
>    Affects Versions: 3.4.11, 3.4.12, 3.4.13, 3.5.5, 3.4.14
>         Environment: 	Ubuntu 16.04.3 LTS
> 	Open JDK version "1.8.0_191" build 25.191-b12
>            Reporter: xiaoqin.fu
>            Priority: Minor
>
>     public static void logTraceMessage(Logger log, long mask, String msg) {
>         if (isTraceEnabled(log, mask)) {
>             log.trace(msg);
>         }
>     }
>     static public void logQuorumPacket(Logger log, long mask,
>             char direction, QuorumPacket qp)
>     {
>         if (isTraceEnabled(log, mask)) { 
>             logTraceMessage(log, mask, direction +
>                     " " + LearnerHandler.packetToString(qp));
>          }
>     }	
> 	
> 	We should remove one of two "if (isTraceEnabled(log, mask))" conditional statements:
> 	
>     public static void logTraceMessage(Logger log, long mask, String msg) {
>         if (isTraceEnabled(log, mask)) {
>             log.trace(msg);
>         }
>     }
>     static public void logQuorumPacket(Logger log, long mask,
>             char direction, QuorumPacket qp)
>     {
>             logTraceMessage(log, mask, direction +
>                     " " + LearnerHandler.packetToString(qp));        
>     }		



--
This message was sent by Atlassian Jira
(v8.3.4#803005)