@Test(expected=ProcessingException.class) public void testGetXmxValueIncorrectInput2(){ String jc = " -Xmx1024Q" ; @SuppressWarnings("unused") Long value = JobHistoryFileParserBase.getXmxValue(jc); }
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);  }