private Double getJobCost ( Long mbMillis , Configuration currentConf ) { Double computeTco = 0.0 ; Long machineMemory = 0L ; Properties prop = null ; String machineType = currentConf . get ( Constants . HRAVEN_MACHINE_TYPE , "default" ) ; LOG . debug ( " machine type " + machineType ) ; try { Path [ ] cacheFiles = DistributedCache . getLocalCacheFiles ( currentConf ) ; if ( null != cacheFiles && cacheFiles . length > 0 ) { for ( Path cachePath : cacheFiles ) { LOG . debug ( " distributed cache path " + cachePath ) ; if ( cachePath . getName ( ) . equals ( Constants . COST_PROPERTIES_FILENAME ) ) { prop = loadCostProperties ( cachePath , machineType ) ; break ; } } } else { LOG . error ( "Unable to find anything (" + Constants . COST_PROPERTIES_FILENAME + ") in distributed cache, continuing with defaults" ) ; } } catch ( IOException ioe ) { LOG . error ( "IOException reading from distributed cache for " + Constants . COST_PROPERTIES_HDFS_DIR + ", continuing with defaults" + ioe . toString ( ) ) ; } if ( prop != null ) { String computeTcoStr = prop . getProperty ( machineType + ".computecost" ) ; try { computeTco = Double . parseDouble ( computeTcoStr ) ; } catch ( NumberFormatException nfe ) { LOG . error ( "error in conversion to long for compute tco " + computeTcoStr + " using default value of 0" ) ; } String machineMemStr = prop . getProperty ( machineType + ".machinememory" ) ; try { machineMemory = Long . parseLong ( machineMemStr ) ; } catch ( NumberFormatException nfe ) { LOG . error ( "error in conversion to long for machine memory " + machineMemStr + " using default value of 0" ) ; } } else { LOG . error ( "Could not load properties file, using defaults" ) ; } Double jobCost = JobHistoryFileParserBase . calculateJobCost ( mbMillis , computeTco , machineMemory ) ; LOG . info ( "from cost properties file, jobCost is " + jobCost + " based on compute tco: " + computeTco + " machine memory: " + machineMemory + " for machine type " + machineType ) ; return jobCost ; }
calculates the cost of this job based on mbMillis machineType and cost details from the properties file