public static int getNonNegativeInt(Configuration conf, String key, int defaultValue) {
    try {
      int value = conf.getInt(key, defaultValue);
      if (value < 0) {
        value = 0;
        logger.warn("Configuration " + key + " is negative. Resetting it to 0");
      }
      return value;
    } catch (NumberFormatException e) {
      logger.error("Invalid configuration " + key + ". Value is " + conf.get(key)
              + ". Resetting it to default value: " + defaultValue);
      return defaultValue;
    }
  }
Get non negative int value from Configuration.

If the value is not set or not an integer, the provided default value is returned.
If the value is negative, 0 is returned.

@param conf Configuration to be extracted
@param key property name
@param defaultValue default value
@return non negative int value
app/com/linkedin/drelephant/util/Utils.java