MAPREDUCE-7354. Use empty array constant present in TaskCompletionEvent to avoid creating redundant objects (#3123)
Reviewed-by: Hui Fei <ferhui@apache.org> Reviewed-by: Akira Ajisaka <aajisaka@apache.org>
This commit is contained in:
parent
c488abbc79
commit
6e11461eaa
@ -146,7 +146,7 @@ public class JobImpl implements org.apache.hadoop.mapreduce.v2.app.job.Job,
|
|||||||
EMPTY_TASK_ATTEMPT_COMPLETION_EVENTS = new TaskAttemptCompletionEvent[0];
|
EMPTY_TASK_ATTEMPT_COMPLETION_EVENTS = new TaskAttemptCompletionEvent[0];
|
||||||
|
|
||||||
private static final TaskCompletionEvent[]
|
private static final TaskCompletionEvent[]
|
||||||
EMPTY_TASK_COMPLETION_EVENTS = new TaskCompletionEvent[0];
|
EMPTY_TASK_COMPLETION_EVENTS = TaskCompletionEvent.EMPTY_ARRAY;
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(JobImpl.class);
|
private static final Logger LOG = LoggerFactory.getLogger(JobImpl.class);
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public void testJobToString() throws IOException, InterruptedException {
|
|||||||
when(client.getTaskReports(jobid, TaskType.REDUCE)).thenReturn(
|
when(client.getTaskReports(jobid, TaskType.REDUCE)).thenReturn(
|
||||||
new TaskReport[0]);
|
new TaskReport[0]);
|
||||||
when(client.getTaskCompletionEvents(jobid, 0, 10)).thenReturn(
|
when(client.getTaskCompletionEvents(jobid, 0, 10)).thenReturn(
|
||||||
new TaskCompletionEvent[0]);
|
TaskCompletionEvent.EMPTY_ARRAY);
|
||||||
Job job = Job.getInstance(cluster, status, new JobConf());
|
Job job = Job.getInstance(cluster, status, new JobConf());
|
||||||
Assert.assertNotNull(job.toString());
|
Assert.assertNotNull(job.toString());
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,6 @@
|
|||||||
import org.apache.log4j.Level;
|
import org.apache.log4j.Level;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.apache.log4j.WriterAppender;
|
import org.apache.log4j.WriterAppender;
|
||||||
import org.mockito.invocation.InvocationOnMock;
|
|
||||||
import org.mockito.stubbing.Answer;
|
import org.mockito.stubbing.Answer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,15 +80,9 @@ public void testJobMonitorAndPrint() throws Exception {
|
|||||||
1f, 1f, State.SUCCEEDED, JobPriority.HIGH, "tmp-user", "tmp-jobname",
|
1f, 1f, State.SUCCEEDED, JobPriority.HIGH, "tmp-user", "tmp-jobname",
|
||||||
"tmp-queue", "tmp-jobfile", "tmp-url", true);
|
"tmp-queue", "tmp-jobfile", "tmp-url", true);
|
||||||
|
|
||||||
doAnswer(
|
doAnswer((Answer<TaskCompletionEvent[]>) invocation ->
|
||||||
new Answer<TaskCompletionEvent[]>() {
|
TaskCompletionEvent.EMPTY_ARRAY).when(job)
|
||||||
@Override
|
.getTaskCompletionEvents(anyInt(), anyInt());
|
||||||
public TaskCompletionEvent[] answer(InvocationOnMock invocation)
|
|
||||||
throws Throwable {
|
|
||||||
return new TaskCompletionEvent[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
).when(job).getTaskCompletionEvents(anyInt(), anyInt());
|
|
||||||
|
|
||||||
doReturn(new TaskReport[5]).when(job).getTaskReports(isA(TaskType.class));
|
doReturn(new TaskReport[5]).when(job).getTaskReports(isA(TaskType.class));
|
||||||
when(clientProtocol.getJobStatus(any(JobID.class))).thenReturn(jobStatus_1, jobStatus_2);
|
when(clientProtocol.getJobStatus(any(JobID.class))).thenReturn(jobStatus_1, jobStatus_2);
|
||||||
|
@ -183,7 +183,7 @@ public TaskAttemptCompletionEvent[] getTaskAttemptCompletionEvents(
|
|||||||
@Override
|
@Override
|
||||||
public TaskCompletionEvent[] getMapAttemptCompletionEvents(
|
public TaskCompletionEvent[] getMapAttemptCompletionEvents(
|
||||||
int startIndex, int maxEvents) {
|
int startIndex, int maxEvents) {
|
||||||
return new TaskCompletionEvent[0];
|
return TaskCompletionEvent.EMPTY_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user