diff --git a/app/com/linkedin/drelephant/ElephantFetcher.java b/app/com/linkedin/drelephant/ElephantFetcher.java index d2a557768..180f6a690 100644 --- a/app/com/linkedin/drelephant/ElephantFetcher.java +++ b/app/com/linkedin/drelephant/ElephantFetcher.java @@ -87,7 +87,11 @@ private TaskReport[] getReduceTaskReports(JobID job_id) throws IOException { } public JobStatus[] getJobList() throws IOException { - return jobClient.getAllJobs(); + JobStatus[] result = jobClient.getAllJobs(); + if(result == null) { + throw new IOException("Unable to connect to Jobtracker"); + } + return result; } public Properties getJobConf(RunningJob job) throws IOException, AuthenticationException { diff --git a/app/com/linkedin/drelephant/ElephantRunner.java b/app/com/linkedin/drelephant/ElephantRunner.java index 5e998997c..91fd61cc7 100644 --- a/app/com/linkedin/drelephant/ElephantRunner.java +++ b/app/com/linkedin/drelephant/ElephantRunner.java @@ -54,9 +54,6 @@ public Void run() { logger.info("Fetching job list."); hadoopSecurity.checkLogin(); JobStatus[] jobs = fetcher.getJobList(); - if (jobs == null) { - throw new IllegalArgumentException("Jobtracker returned 'null' for job list"); - } Set successJobs = filterSuccessfulJobs(jobs); successJobs = filterPreviousJobs(successJobs, previousJobs); @@ -83,7 +80,7 @@ public Void run() { try { Thread.sleep(waitTime); } catch (InterruptedException e) { - e.printStackTrace(); + logger.error("Thread interrupted", e); } waitTime = nextRun - System.currentTimeMillis(); } diff --git a/app/com/linkedin/drelephant/util/Utils.java b/app/com/linkedin/drelephant/util/Utils.java index 26a712e2d..1a37516eb 100644 --- a/app/com/linkedin/drelephant/util/Utils.java +++ b/app/com/linkedin/drelephant/util/Utils.java @@ -1,6 +1,7 @@ package com.linkedin.drelephant.util; import java.util.ArrayList; +import java.util.List; public class Utils { @@ -38,8 +39,8 @@ public static String[][] parseCsvLines(String data) { } public static String[] parseCsvLine(String line) { - ArrayList store = new ArrayList(); - StringBuffer curVal = new StringBuffer(); + List store = new ArrayList(); + StringBuilder curVal = new StringBuilder(); boolean inquotes = false; for (int i = 0; i < line.length(); i++) { char ch = line.charAt(i); @@ -59,7 +60,7 @@ public static String[] parseCsvLine(String line) { } } else if (ch == ',') { store.add(curVal.toString()); - curVal = new StringBuffer(); + curVal = new StringBuilder(); } else { curVal.append(ch); }