public String getAppId(Configuration jobConf) {

    // Defensive coding
    if (jobConf == null) {
      return Constants.UNKNOWN;
    }

    String appId = jobConf.get(Constants.APP_NAME_CONF_KEY);

    // If explicit app name isn't set, try to parse it from mapred.job.name
    if (StringUtils.isBlank(appId)) {
      appId = jobConf.get(Constants.JOB_NAME_CONF_KEY);
      if (StringUtils.isNotBlank(appId)) {
        // Allow sub-classes to transform.
        appId = getAppIdFromJobName(appId);
      } else {
        // look for a hadoop2 conf key mapreduce.job.name
        appId = jobConf.get(Constants.JOB_NAME_HADOOP2_CONF_KEY);
        if (StringUtils.isNotBlank(appId)) {
          // Allow sub-classes to transform.
          appId = getAppIdFromJobName(appId);
        }
      }
    }

    return cleanAppId(appId);
  }
public String getAppId ( Configuration jobConf ) { if ( jobConf == null ) { return Constants . UNKNOWN ; } String appId = jobConf . get ( Constants . APP_NAME_CONF_KEY ) ; if ( StringUtils . isBlank ( appId ) ) { appId = jobConf . get ( Constants . JOB_NAME_CONF_KEY ) ; if ( StringUtils . isNotBlank ( appId ) ) { appId = getAppIdFromJobName ( appId ) ; } else { appId = jobConf . get ( Constants . JOB_NAME_HADOOP2_CONF_KEY ) ; if ( StringUtils . isNotBlank ( appId ) ) { appId = getAppIdFromJobName ( appId ) ; } } } return cleanAppId ( appId ) ; }
@param jobConf
from which to pull the properties
@return a non-empty non-null string with the jobId. If the jobId cannot be
parsed, then {@link Constants#UNKNOWN} will be returned.