Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Plain View
HDFS >> mail # dev >> Convention question for using DFSConfigKey constants : are zeros magic?


Copy link to this message
-
Convention question for using DFSConfigKey constants : are zeros magic?
I recently looked into the HDFS source tree to determine idioms with
respect to a hairy debate about the threshold between what is and is not a
magic number, and found that :  And it appears that the number zero is NOT
considered magic - at least not in the HDFS source code.

I found that that DFSConfigKeys.java defines DEFAULT values of zeros for
some fields, and those defaults result in non-quantitative interpretation
of the field.

For example:
dfs.image.transfer.bandwidthPerSec

Is commented like so:
public static final long DFS_IMAGE_TRANSFER_RATE_DEFAULT = 0;  //no
throttling

However in the implementation of these defaults, "magic" zeros are used
without commenting:
if (transferBandwidth > 0) {
      throttler = new DataTransferThrottler(transferBandwidth);
}

--------

Seems like the 0 above would be better replaced with
DFS_IMAGE_TRANSFER_RATE_DEFAULT since the "no throttling" behaviour is
defined with the constant in the DFSConfigKeys file, and not defined in the
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/GetImageServlet.java.
--------

Trying to get a feel for if there are conventions  to enforce in some code
reviews for our hadoop dependent configuration code.  We'd like to follow
hadoopy idioms if possible..
--
Jay Vyas
http://jayunit100.blogspot.com
+
Aaron T. Myers 2013-04-19, 18:23
+
Jay Vyas 2013-04-19, 22:40
+
Aaron T. Myers 2013-04-24, 02:15
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB