MAPREDUCE-6693. ArrayIndexOutOfBoundsException occurs when the length of the job name is equal to mapreduce.jobhistory.jobname.limit. Contributed by Ajith S.
(cherry picked from commit b357930526
)
This commit is contained in:
parent
7f03c1c90e
commit
19db965c27
|
@ -311,7 +311,7 @@ public class FileNameIndexUtils {
|
||||||
String encodedString, int limitLength) {
|
String encodedString, int limitLength) {
|
||||||
assert(limitLength >= 0) : "limitLength should be positive integer";
|
assert(limitLength >= 0) : "limitLength should be positive integer";
|
||||||
|
|
||||||
if (encodedString.length() < limitLength) {
|
if (encodedString.length() <= limitLength) {
|
||||||
return encodedString;
|
return encodedString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -481,4 +481,29 @@ public class TestFileNameIndexUtils {
|
||||||
Assert.assertNull("Queue name incorrect after decoding old history file",
|
Assert.assertNull("Queue name incorrect after decoding old history file",
|
||||||
info.getQueueName());
|
info.getQueueName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTrimJobNameEqualsLimitLength() throws IOException {
|
||||||
|
int jobNameTrimLength = 9;
|
||||||
|
JobIndexInfo info = new JobIndexInfo();
|
||||||
|
JobID oldJobId = JobID.forName(JOB_ID);
|
||||||
|
JobId jobId = TypeConverter.toYarn(oldJobId);
|
||||||
|
info.setJobId(jobId);
|
||||||
|
info.setSubmitTime(Long.parseLong(SUBMIT_TIME));
|
||||||
|
info.setUser(USER_NAME);
|
||||||
|
info.setJobName(JOB_NAME);
|
||||||
|
info.setFinishTime(Long.parseLong(FINISH_TIME));
|
||||||
|
info.setNumMaps(Integer.parseInt(NUM_MAPS));
|
||||||
|
info.setNumReduces(Integer.parseInt(NUM_REDUCES));
|
||||||
|
info.setJobStatus(JOB_STATUS);
|
||||||
|
info.setQueueName(QUEUE_NAME);
|
||||||
|
info.setJobStartTime(Long.parseLong(JOB_START_TIME));
|
||||||
|
|
||||||
|
String jobHistoryFile = FileNameIndexUtils.getDoneFileName(info,
|
||||||
|
jobNameTrimLength);
|
||||||
|
JobIndexInfo parsedInfo = FileNameIndexUtils.getIndexInfo(jobHistoryFile);
|
||||||
|
|
||||||
|
Assert.assertEquals("Job name did not get trimmed correctly", info
|
||||||
|
.getJobName().substring(0, jobNameTrimLength), parsedInfo.getJobName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue