Get the attempt number
@param conf Configuration
@return Attempt number
@throws IllegalArgumentException
482283
public static int getAttemptId(Configuration conf)
      throws IllegalArgumentException {
    if (conf == null) {
      throw new NullPointerException("Conf is null");
    }

    String taskId = conf.get("mapred.task.id");
    if (taskId == null) {
      throw new IllegalArgumentException(
          "Configuration does not contain the property mapred.task.id");
    }

    String[] parts = taskId.split("_");
    if (parts.length != 6 ||
        !parts[0].equals("attempt") ||
        (!"m".equals(parts[3]) && !"r".equals(parts[3]))) {
      throw new IllegalArgumentException(
          "TaskAttemptId string : " + taskId + " is not properly formed");
    }

    return Integer.parseInt(parts[5]);
  }
1057244
public int getJvmPid() {
        int pid = -1;
        if (strPID !=null) {
            try {
                pid = Integer.parseInt(strPID);
            }
            catch (NumberFormatException e) {/* */  }
        }
        return pid;
    }
99619
public static long getTxInfoCacheWeight(FluoConfiguration conf) {
    long size = conf.getLong(TX_INFO_CACHE_WEIGHT, TX_INFO_CACHE_WEIGHT_DEFAULT);
    if (size <= 0) {
      throw new IllegalArgumentException("Cache size must be positive for " + TX_INFO_CACHE_WEIGHT);
    }
    return size;
  }
451067
@com.netflix.servo.annotations.Monitor(name = "numOfASGQueryFailures",
            description = "Number of queries made to AWS to retrieve ASG information and that failed",
            type = DataSourceType.COUNTER)
    public long getNumberofASGQueryFailures() {
        return asgCache.stats().loadExceptionCount();
    }
286057
public static String getUserNameInConf(Configuration jobConf)
			throws IllegalArgumentException {
		String userName = jobConf.get(Constants.USER_CONF_KEY_HADOOP2);
		if (StringUtils.isBlank(userName)) {
			userName = jobConf.get(Constants.USER_CONF_KEY);
			if (StringUtils.isBlank(userName)) {
				// neither user.name nor hadoop.mapreduce.job.user.name found
				throw new IllegalArgumentException(" Found neither "
						+ Constants.USER_CONF_KEY + " nor "
						+ Constants.USER_CONF_KEY_HADOOP2);
			}
		}
		return userName;
	}
892331
@Override
    public double getLoadExceptionRate() {
        long totalLoadCount = loadSuccessCount.get() + loadExceptionCount.get();
        return (totalLoadCount == 0) ? 0.0 : (double) loadExceptionCount.get() / totalLoadCount;
    }
395813
function Config(conf){
  try{
    if(typeof conf === 'string'){
      this.confPath = conf;
      conf = ini.parse(fs.readFileSync(conf, 'utf8'));
    }
  }catch(e){
    conf = {}
  }
  this.conf= conf || {};
}
1312621
@Override
    public String getId() throws NotAvailableException {
        try {
            String tmpId = (String) getConfigField(TYPE_FIELD_ID);
            if (tmpId.isEmpty()) {
                throw new InvalidStateException("config.id is empty!");
            }
            return tmpId;
        } catch (CouldNotPerformException ex) {
            logger.debug("Config does not contain the remote id!");
        }
        return super.getId();
    }
195753
public static int getIntValue(Config stormConf, String key, int defaultValue)
    {
        Object config = stormConf.get(key);

        if (config == null)
        {
            return defaultValue;
        }

        return Integer.parseInt(config.toString());
    }
710314
public int getParameterAsInt(ConfigKey pConfigKey) {
        String intValueS = processingConfig.get(pConfigKey);
        if (intValueS != null) {
            return Integer.parseInt(intValueS);
        } else {
            return 0;
        }
    }
595949
private Throwable getPropogatedError() {
		Request req = getRequest();

		if (req != null) {
			return (Throwable) req.getAttribute(ACTION_ERROR_KEY);
		}

		return null;
	}
1250365
public static int getErrorCode(Throwable t) {
    // Error codes and their explanations are described in
    // the Errno.java in jnr-constants
    if (t instanceof AlluxioException) {
      return getAlluxioErrorCode((AlluxioException) t);
    } else if (t instanceof IOException) {
      return -ErrorCodes.EIO();
    } else {
      return -ErrorCodes.EBADMSG();
    }
  }
1217340
protected int getListingChunkLength(AlluxioConfiguration conf) {
    return conf.getInt(PropertyKey.UNDERFS_LISTING_LENGTH) > getListingChunkLengthMax()
        ? getListingChunkLengthMax() : conf.getInt(PropertyKey.UNDERFS_LISTING_LENGTH);
  }
638681
public static String getDefaultAddress(Configuration conf) {
    URI uri = FileSystem.getDefaultUri(conf);
    String authority = uri.getAuthority();
    if (authority == null) {
      throw new IllegalArgumentException(String.format(
          "Invalid URI for NameNode address (check %s): %s has no authority.",
          FileSystem.FS_DEFAULT_NAME_KEY, uri.toString()));
    }
    return authority;
  }
1064659
public int checkCanExceptionMessage()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "checkCanExceptionMessage");

        // Return code
        int rc = DestinationHandler.OUTPUT_HANDLER_NOT_FOUND;

        String newExceptionDestination = null;

        boolean usingDefault = false;

        if (_originalDestination != null)
        {
            newExceptionDestination = _originalDestination.getExceptionDestination();
            if (newExceptionDestination == null || newExceptionDestination.equals(""))
            {
                // Simply return with OUTPUT_HANDLER_NOT_FOUND
                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    SibTr.exit(tc, "checkCanExceptionMessage", rc);
                return rc;
            }
            if (newExceptionDestination.equals(JsConstants.DEFAULT_EXCEPTION_DESTINATION))
            {
                newExceptionDestination = _defaultExceptionDestinationName;
                usingDefault = true;
            }
        }
        else
        {
            newExceptionDestination = _defaultExceptionDestinationName;
            usingDefault = true;
        }

        try
        {
            DestinationHandler exceptionDestHandler =
                            _messageProcessor.getDestinationManager().
                                            getDestination(newExceptionDestination, true);

            rc = exceptionDestHandler.checkCanAcceptMessage(null, null);
        } catch (SIException e)
        {
            // No FFDC code needed

            SibTr.exception(tc, e);
        }

        // If we havent checked the system default destination, then do that now
        if (rc != DestinationHandler.OUTPUT_HANDLER_FOUND && !usingDefault)
        {
            try
            {
                DestinationHandler exceptionDestHandler =
                                _messageProcessor.getDestinationManager().
                                                getDestination(_defaultExceptionDestinationName, true);

                rc = exceptionDestHandler.checkCanAcceptMessage(null, null);
            } catch (SIException e)
            {
                // No FFDC code needed

                SibTr.exception(tc, e);
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "checkCanExceptionMessage", Integer.valueOf(rc));

        return rc;
    }
1056297
private static String[] prepareDefaultConf() throws IOException {
    final File templateFolder = new File("test/local-conf-templates");
    final File localConfFolder = new File("local/conf");
    if (!localConfFolder.exists()) {
      FileUtils.copyDirectory(templateFolder, localConfFolder.getParentFile());
      log.info("Copied local conf templates from " + templateFolder.getAbsolutePath());
    }
    log.info("Using conf at " + localConfFolder.getAbsolutePath());
    return new String[]{"-conf", "local/conf"};
  }
507065
public int getTrackNumberNumeric() {
        String number = getTrackNumber();

        if(number == null) return -1;
        try {
            return Integer.parseInt(number);
        } catch(NumberFormatException e) {
            return -1;
        }
    }