diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezJobMonitor.java ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezJobMonitor.java index 9bcdeed..a171062 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezJobMonitor.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezJobMonitor.java @@ -58,6 +58,8 @@ private final int checkInterval = 200; private final int maxRetryInterval = 2500; private final int printInterval = 3000; + private final int progressBarChars = 25; + private final int progressDevisor = 100 / Math.min(100, progressBarChars); private long lastPrintTime; private Set completed; private static final List shutdownList; @@ -221,9 +223,29 @@ public static void killRunningJobs() { } } } + + private StringBuilder printProgressBar(int percent) { + StringBuilder bar = new StringBuilder("["); + + for (int i = 0; i < progressBarChars; i++) { + if (i < (percent / progressDevisor)) { + bar.append("="); + } else if (i == (percent / progressDevisor)) { + bar.append(">"); + } else { + bar.append(" "); + } + } + + bar.append("] " + percent + "% "); + return bar; + } private String printStatus(Map progressMap, String lastReport, LogHelper console) { StringBuffer reportBuffer = new StringBuffer(); + int progressPercentage = 0; + int sumComplete = 0; + int sumTotal = 0; SortedSet keys = new TreeSet(progressMap.keySet()); for (String s: keys) { @@ -232,6 +254,9 @@ private String printStatus(Map progressMap, String lastReport, final int total = progress.getTotalTaskCount(); final int running = progress.getRunningTaskCount(); final int failed = progress.getFailedTaskCount(); + sumComplete += complete; + sumTotal += total; + if (total <= 0) { reportBuffer.append(String.format("%s: -/-\t", s, complete, total)); } else { @@ -257,8 +282,11 @@ private String printStatus(Map progressMap, String lastReport, } } } + + progressPercentage = (sumTotal == 0) ? 0 : 100 * sumComplete / sumTotal; - String report = reportBuffer.toString(); + String report = printProgressBar(progressPercentage).toString() + reportBuffer.toString(); + if (!report.equals(lastReport) || System.currentTimeMillis() >= lastPrintTime + printInterval) { console.printInfo(report); lastPrintTime = System.currentTimeMillis();