@Override public Counters getCounters() { if (hasFailedTasks) { return null; } return new Counters( TypeConverter.fromYarn(report.getCounters())); }
@Test public void testSetRawCounters() { // Create basic class TaskReport report = Records.newRecord(TaskReport.class); org.apache.hadoop.mapreduce.Counters rCounters = MockJobs.newCounters(); // Set raw counters report.setRawCounters(rCounters); // Verify getCounters converts properly from raw to real Counters counters = report.getCounters(); assertNotEquals(null, counters); }
@Test public void testSetNonNullCountersToNull() { // Create basic class TaskReport report = Records.newRecord(TaskReport.class); // Set raw counters org.apache.hadoop.mapreduce.Counters rCounters = MockJobs.newCounters(); report.setRawCounters(rCounters); // Verify getCounters converts properly from raw to real Counters counters = report.getCounters(); assertNotEquals(null, counters); // Clear counters to null and then verify report.setCounters(null); assertEquals(null, report.getCounters()); assertEquals(null, report.getRawCounters()); }
@Test public void testUninitializedCounters() { // Create basic class TaskReport report = Records.newRecord(TaskReport.class); // Verify properties initialized to null assertEquals(null, report.getCounters()); assertEquals(null, report.getRawCounters()); }
@Test public void testSetNonNullRawCountersToNull() { // Create basic class TaskReport report = Records.newRecord(TaskReport.class); // Set raw counters org.apache.hadoop.mapreduce.Counters rCounters = MockJobs.newCounters(); report.setRawCounters(rCounters); // Verify getCounters converts properly from raw to real Counters counters = report.getCounters(); assertNotEquals(null, counters); // Clear counters to null and then verify report.setRawCounters(null); assertEquals(null, report.getCounters()); assertEquals(null, report.getRawCounters()); } }
public static TaskReport fromYarn(org.apache.hadoop.mapreduce.v2.api.records.TaskReport report) { String[] diagnostics = null; if (report.getDiagnosticsList() != null) { diagnostics = new String[report.getDiagnosticsCount()]; int i = 0; for (String cs : report.getDiagnosticsList()) { diagnostics[i++] = cs.toString(); } } else { diagnostics = new String[0]; } TaskReport rep = new TaskReport(fromYarn(report.getTaskId()), report.getProgress(), report.getTaskState().toString(), diagnostics, fromYarn(report.getTaskState()), report.getStartTime(), report.getFinishTime(), fromYarn(report.getCounters())); List<org.apache.hadoop.mapreduce.TaskAttemptID> runningAtts = new ArrayList<org.apache.hadoop.mapreduce.TaskAttemptID>(); for (org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptId id : report.getRunningAttemptsList()) { runningAtts.add(fromYarn(id)); } rep.setRunningTaskAttemptIds(runningAtts); if (report.getSuccessfulAttempt() != null) { rep.setSuccessfulAttemptId(fromYarn(report.getSuccessfulAttempt())); } return rep; }
@Test public void testSetRawCountersToNull() { // Create basic class TaskReport report = Records.newRecord(TaskReport.class); // Set raw counters to null report.setRawCounters(null); // Verify properties still null assertEquals(null, report.getCounters()); assertEquals(null, report.getRawCounters()); }
@Test public void testSetCountersToNull() { // Create basic class TaskReport report = Records.newRecord(TaskReport.class); // Set raw counters to null report.setCounters(null); // Verify properties still null assertEquals(null, report.getCounters()); assertEquals(null, report.getRawCounters()); }
public static TaskReport fromYarn(org.apache.hadoop.mapreduce.v2.api.records.TaskReport report) { String[] diagnostics = null; if (report.getDiagnosticsList() != null) { diagnostics = new String[report.getDiagnosticsCount()]; int i = 0; for (String cs : report.getDiagnosticsList()) { diagnostics[i++] = cs.toString(); } } else { diagnostics = new String[0]; } TaskReport rep = new TaskReport(fromYarn(report.getTaskId()), report.getProgress(), report.getTaskState().toString(), diagnostics, fromYarn(report.getTaskState()), report.getStartTime(), report.getFinishTime(), fromYarn(report.getCounters())); List<org.apache.hadoop.mapreduce.TaskAttemptID> runningAtts = new ArrayList<org.apache.hadoop.mapreduce.TaskAttemptID>(); for (org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptId id : report.getRunningAttemptsList()) { runningAtts.add(fromYarn(id)); } rep.setRunningTaskAttemptIds(runningAtts); if (report.getSuccessfulAttempt() != null) { rep.setSuccessfulAttemptId(fromYarn(report.getSuccessfulAttempt())); } return rep; }
public static TaskReport fromYarn(org.apache.hadoop.mapreduce.v2.api.records.TaskReport report) { String[] diagnostics = null; if (report.getDiagnosticsList() != null) { diagnostics = new String[report.getDiagnosticsCount()]; int i = 0; for (String cs : report.getDiagnosticsList()) { diagnostics[i++] = cs.toString(); } } else { diagnostics = new String[0]; } TaskReport rep = new TaskReport(fromYarn(report.getTaskId()), report.getProgress(), report.getTaskState().toString(), diagnostics, fromYarn(report.getTaskState()), report.getStartTime(), report.getFinishTime(), fromYarn(report.getCounters())); List<org.apache.hadoop.mapreduce.TaskAttemptID> runningAtts = new ArrayList<org.apache.hadoop.mapreduce.TaskAttemptID>(); for (org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptId id : report.getRunningAttemptsList()) { runningAtts.add(fromYarn(id)); } rep.setRunningTaskAttemptIds(runningAtts); if (report.getSuccessfulAttempt() != null) { rep.setSuccessfulAttemptId(fromYarn(report.getSuccessfulAttempt())); } return rep; }
public static TaskReport fromYarn(org.apache.hadoop.mapreduce.v2.api.records.TaskReport report) { String[] diagnostics = null; if (report.getDiagnosticsList() != null) { diagnostics = new String[report.getDiagnosticsCount()]; int i = 0; for (String cs : report.getDiagnosticsList()) { diagnostics[i++] = cs.toString(); } } else { diagnostics = new String[0]; } TaskReport rep = new TaskReport(fromYarn(report.getTaskId()), report.getProgress(), report.getTaskState().toString(), diagnostics, fromYarn(report.getTaskState()), report.getStartTime(), report.getFinishTime(), fromYarn(report.getCounters())); List<org.apache.hadoop.mapreduce.TaskAttemptID> runningAtts = new ArrayList<org.apache.hadoop.mapreduce.TaskAttemptID>(); for (org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptId id : report.getRunningAttemptsList()) { runningAtts.add(fromYarn(id)); } rep.setRunningTaskAttemptIds(runningAtts); if (report.getSuccessfulAttempt() != null) { rep.setSuccessfulAttemptId(fromYarn(report.getSuccessfulAttempt())); } return rep; }
@Test public void testCountersOverRawCounters() { // Create basic class TaskReport report = Records.newRecord(TaskReport.class); org.apache.hadoop.mapreduce.Counters rCounters = MockJobs.newCounters(); Counters altCounters = TypeConverter.toYarn(rCounters); // Set raw counters report.setRawCounters(rCounters); // Set real counters report.setCounters(altCounters); // Verify real counters has priority over raw Counters counters = report.getCounters(); assertNotEquals(null, counters); assertNotEquals(rCounters, altCounters); assertEquals(counters, altCounters); }