Return-Path: Delivered-To: apmail-hadoop-core-dev-archive@www.apache.org Received: (qmail 1600 invoked from network); 11 Dec 2008 19:11:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Dec 2008 19:11:11 -0000 Received: (qmail 79496 invoked by uid 500); 11 Dec 2008 19:11:20 -0000 Delivered-To: apmail-hadoop-core-dev-archive@hadoop.apache.org Received: (qmail 79443 invoked by uid 500); 11 Dec 2008 19:11:20 -0000 Mailing-List: contact core-dev-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: core-dev@hadoop.apache.org Delivered-To: mailing list core-dev@hadoop.apache.org Received: (qmail 79160 invoked by uid 99); 11 Dec 2008 19:11:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Dec 2008 11:11:20 -0800 X-ASF-Spam-Status: No, hits=-4.0 required=10.0 tests=RCVD_IN_DNSWL_MED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Dec 2008 19:11:05 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 5B1EE234C388 for ; Thu, 11 Dec 2008 11:10:44 -0800 (PST) Message-ID: <1960207874.1229022644372.JavaMail.jira@brutus> Date: Thu, 11 Dec 2008 11:10:44 -0800 (PST) From: "Sanjay Radia (JIRA)" To: core-dev@hadoop.apache.org Subject: [jira] Commented: (HADOOP-3470) Bad coding style: The member fields in org.apache.hadoop.ipc.metrics.RpcMetrics are public In-Reply-To: <867616885.1212172845431.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HADOOP-3470?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12655743#action_12655743 ] Sanjay Radia commented on HADOOP-3470: -------------------------------------- Generally member fields should be accessed via getters and setter. In this particular case the purpose of the metrics holder class (such as RPCMetrics or NameNodeMetrics, etc is to be place holder of the a list of metrics variables that are then accessed in various parts of the code to change the counters. Forcing a set of new methods per metrics (since a metrics may have multiple operations) is very painful and will make it harder to add new metrics. Adding metrics should be simple" - declare metrics variable (eg. counter) - write code to change the metrics variable (e.g inc the counter). (btw HADOOP-4838 simplifies metrics so that only the above two steps are needed.) I believe the metrics variables are one of the exception to style rule of using getters and setter for fields. (Note HADOOP4848 has added a registry and hence it would be easy to have the callers use that map but the cost of that would be too much for changing counters (ie a map lookup operation per counter increment!!) > Bad coding style: The member fields in org.apache.hadoop.ipc.metrics.RpcMetrics are public > ------------------------------------------------------------------------------------------ > > Key: HADOOP-3470 > URL: https://issues.apache.org/jira/browse/HADOOP-3470 > Project: Hadoop Core > Issue Type: Improvement > Components: metrics > Reporter: Tsz Wo (Nicholas), SZE > > In org.apache.hadoop.ipc.metrics.RpcMetrics, > {code} > //the following are member fields > public MetricsTimeVaryingRate rpcQueueTime = new MetricsTimeVaryingRate("RpcQueueTime"); > public MetricsTimeVaryingRate rpcProcessingTime = new MetricsTimeVaryingRate("RpcProcessingTime"); > public Map metricsList = Collections.synchronizedMap(new HashMap()); > {code} > Then, the fields are accessed directly in other classes. For example, org.apache.hadoop.ipc.RPC.Server.call(...) > {code} > ... > MetricsTimeVaryingRate m = rpcMetrics.metricsList.get(call.getMethodName()); > if (m != null) { > m.inc(processingTime); > } > else { > rpcMetrics.metricsList.put(call.getMethodName(), new MetricsTimeVaryingRate(call.getMethodName())); > m = rpcMetrics.metricsList.get(call.getMethodName()); > m.inc(processingTime); > } > {code} -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.