@Test public void testGetXmxValue(){ String xmxValue = "-Xmx500m"; long expValue = 500; long actualValue = JobHistoryFileParserBase.getXmxValue(xmxValue); assertEquals(expValue, actualValue); long totalValue = JobHistoryFileParserBase.getXmxTotal(actualValue); assertEquals(666L, totalValue); xmxValue = "-Xmx2048K"; actualValue = JobHistoryFileParserBase.getXmxValue(xmxValue); expValue = 2L; assertEquals(expValue, actualValue); totalValue = JobHistoryFileParserBase.getXmxTotal(actualValue); long expTotalVal = 2L; assertEquals(expTotalVal, totalValue); xmxValue = "-Xmx2G"; actualValue = JobHistoryFileParserBase.getXmxValue(xmxValue); expValue = 2048; assertEquals(expValue, actualValue); totalValue = JobHistoryFileParserBase.getXmxTotal(actualValue); expTotalVal = 2730L; assertEquals(expTotalVal, totalValue); xmxValue = "-Xmx2G -Xms 1G -Xmx4G"; actualValue = JobHistoryFileParserBase.getXmxValue(xmxValue); expValue = 2048; assertEquals(expValue, actualValue); totalValue = JobHistoryFileParserBase.getXmxTotal(actualValue); expTotalVal = 2730L; assertEquals(expTotalVal, totalValue); xmxValue = "-Xmx2097152"; actualValue = JobHistoryFileParserBase.getXmxValue(xmxValue); expValue = 2L; assertEquals(expValue, actualValue); totalValue = JobHistoryFileParserBase.getXmxTotal(actualValue); expTotalVal = 2L; assertEquals(expTotalVal, totalValue); xmxValue = " -Xmx1024m -verbose:gc -Xloggc:/tmp/@taskid@.gc" ; actualValue = JobHistoryFileParserBase.getXmxValue(xmxValue); expValue = 1024L; assertEquals(expValue, actualValue); totalValue = JobHistoryFileParserBase.getXmxTotal(actualValue); expTotalVal = 1365L; assertEquals(expTotalVal, totalValue); }
public static long getXmxValue(String javaChildOptsStr) { long retVal = 0L; String valueStr = extractXmxValueStr(javaChildOptsStr); char lastChar = valueStr.charAt(valueStr.length() - 1); try { if (Character.isLetter(lastChar)) { String xmxValStr = valueStr.substring(0, valueStr.length() - 1); retVal = Long.parseLong(xmxValStr); switch (lastChar) { case 'M': case 'm': break; case 'K': case 'k': retVal /= 1024; break; case 'G': case 'g': retVal *= 1024; break; default: throw new ProcessingException("Unable to get the Xmx value from " + javaChildOptsStr + " invalid value for Xmx " + xmxValStr); } } else { retVal = Long.parseLong(valueStr); retVal /= (1024 * 1024); } } catch (NumberFormatException nfe) { LOG.error("Unable to get the Xmx value from " + javaChildOptsStr + "\n", nfe); throw new ProcessingException("Unable to get the Xmx value from " + javaChildOptsStr, nfe); } return retVal; }
JobHistoryFileParserBase implements JobHistoryFileParser { public static long getXmxValue(String javaChildOptsStr) { long retVal = 0L; String valueStr = extractXmxValueStr(javaChildOptsStr); char lastChar = valueStr.charAt(valueStr.length() - 1); try { if (Character.isLetter(lastChar)) { String xmxValStr = valueStr.substring(0, valueStr.length() - 1); retVal = Long.parseLong(xmxValStr); switch (lastChar) { case 'M': case 'm': break; case 'K': case 'k': retVal /= 1024; break; case 'G': case 'g': retVal *= 1024; break; default: throw new ProcessingException("Unable to get the Xmx value from " + javaChildOptsStr + " invalid value for Xmx " + xmxValStr); } } else { retVal = Long.parseLong(valueStr); retVal /= (1024 * 1024); } } catch (NumberFormatException nfe) { LOG.error("Unable to get the Xmx value from " + javaChildOptsStr + "\n", nfe); throw new ProcessingException("Unable to get the Xmx value from " + javaChildOptsStr, nfe); } return retVal; } }
JobHistoryFileParserBase implements JobHistoryFileParser { public static long getXmxValue(String javaChildOptsStr) { long retVal = 0L; String valueStr = extractXmxValueStr(javaChildOptsStr); char lastChar = valueStr.charAt(valueStr.length() - 1); try { if (Character.isLetter(lastChar)) { String xmxValStr = valueStr.substring(0, valueStr.length() - 1); retVal = Long.parseLong(xmxValStr); switch (lastChar) { case 'M': case 'm': break; case 'K': case 'k': retVal /= 1024; break; case 'G': case 'g': retVal *= 1024; break; default: throw new ProcessingException("Unable to get the Xmx value from " + javaChildOptsStr + " invalid value for Xmx " + xmxValStr); } } else { retVal = Long.parseLong(valueStr); retVal /= (1024 * 1024); } } catch (NumberFormatException nfe) { LOG.error("Unable to get the Xmx value from " + javaChildOptsStr + "\n", nfe); throw new ProcessingException("Unable to get the Xmx value from " + javaChildOptsStr, nfe); } return retVal; } protected  JobHistoryFileParserBase(Configuration conf); }
JobHistoryFileParserBase implements JobHistoryFileParser { public static long getXmxValue(String javaChildOptsStr) { long retVal = 0L; String valueStr = extractXmxValueStr(javaChildOptsStr); char lastChar = valueStr.charAt(valueStr.length() - 1); try { if (Character.isLetter(lastChar)) { String xmxValStr = valueStr.substring(0, valueStr.length() - 1); retVal = Long.parseLong(xmxValStr); switch (lastChar) { case 'M': case 'm': break; case 'K': case 'k': retVal /= 1024; break; case 'G': case 'g': retVal *= 1024; break; default: throw new ProcessingException("Unable to get the Xmx value from " + javaChildOptsStr + " invalid value for Xmx " + xmxValStr); } } else { retVal = Long.parseLong(valueStr); retVal /= (1024 * 1024); } } catch (NumberFormatException nfe) { LOG.error("Unable to get the Xmx value from " + javaChildOptsStr + "\n", nfe); throw new ProcessingException("Unable to get the Xmx value from " + javaChildOptsStr, nfe); } return retVal; } protected  JobHistoryFileParserBase(Configuration conf); Put getHadoopVersionPut(HadoopVersion historyFileVersion, byte[] jobKeyBytes); static long getXmxValue(String javaChildOptsStr); static long getXmxTotal(final long xmx75); static long getSubmitTimeMillisFromJobHistory(byte[] jobHistoryRaw); static double calculateJobCost(long mbMillis, double computeTco, long machineMemory); }
JobHistoryFileParserBase implements JobHistoryFileParser { public static long getXmxValue(String javaChildOptsStr) { long retVal = 0L; String valueStr = extractXmxValueStr(javaChildOptsStr); char lastChar = valueStr.charAt(valueStr.length() - 1); try { if (Character.isLetter(lastChar)) { String xmxValStr = valueStr.substring(0, valueStr.length() - 1); retVal = Long.parseLong(xmxValStr); switch (lastChar) { case 'M': case 'm': break; case 'K': case 'k': retVal /= 1024; break; case 'G': case 'g': retVal *= 1024; break; default: throw new ProcessingException("Unable to get the Xmx value from " + javaChildOptsStr + " invalid value for Xmx " + xmxValStr); } } else { retVal = Long.parseLong(valueStr); retVal /= (1024 * 1024); } } catch (NumberFormatException nfe) { LOG.error("Unable to get the Xmx value from " + javaChildOptsStr + "\n", nfe); throw new ProcessingException("Unable to get the Xmx value from " + javaChildOptsStr, nfe); } return retVal; } protected  JobHistoryFileParserBase(Configuration conf); Put getHadoopVersionPut(HadoopVersion historyFileVersion, byte[] jobKeyBytes); static long getXmxValue(String javaChildOptsStr); static long getXmxTotal(final long xmx75); static long getSubmitTimeMillisFromJobHistory(byte[] jobHistoryRaw); static double calculateJobCost(long mbMillis, double computeTco, long machineMemory);  }