MAPREDUCE-4169. Container Logs appear in unsorted order (Jonathan Eagles via bobby)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1331012 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Joseph Evans 2012-04-26 18:27:05 +00:00
parent 4b62c68292
commit cda16311a9
3 changed files with 21 additions and 4 deletions

View File

@ -412,6 +412,9 @@ Release 0.23.3 - UNRELEASED
MAPREDUCE-3613. web service calls header contains 2 content types
(tgraves)
MAPREDUCE-4169. Container Logs appear in unsorted order (Jonathan Eagles
via bobby)
Release 0.23.2 - UNRELEASED
INCOMPATIBLE CHANGES

View File

@ -29,6 +29,9 @@
import java.io.IOException;
import java.io.Writer;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
@ -112,8 +115,11 @@ public static class LogValue {
// the entire k-v format
public LogValue(List<String> rootLogDirs, ContainerId containerId) {
this.rootLogDirs = rootLogDirs;
this.rootLogDirs = new ArrayList<String>(rootLogDirs);
this.containerId = containerId;
// Ensure logs are processed in lexical order
Collections.sort(this.rootLogDirs);
}
public void write(DataOutputStream out) throws IOException {
@ -131,7 +137,10 @@ public void write(DataOutputStream out) throws IOException {
continue; // ContainerDir may have been deleted by the user.
}
for (File logFile : containerLogDir.listFiles()) {
// Write out log files in lexical order
File[] logFiles = containerLogDir.listFiles();
Arrays.sort(logFiles);
for (File logFile : logFiles) {
// Write the logFile Type
out.writeUTF(logFile.getName());

View File

@ -30,6 +30,8 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
@ -269,12 +271,15 @@ private void printLogs(Block html, ContainerId containerId,
}
}
} else {
// Just print out the log-types
// Print out log types in lexical order
List<File> containerLogsDirs = getContainerLogDirs(containerId,
dirsHandler);
Collections.sort(containerLogsDirs);
boolean foundLogFile = false;
for (File containerLogsDir : containerLogsDirs) {
for (File logFile : containerLogsDir.listFiles()) {
File[] logFiles = containerLogsDir.listFiles();
Arrays.sort(logFiles);
for (File logFile : logFiles) {
foundLogFile = true;
html.p()
.a(url("containerlogs", $(CONTAINER_ID), $(APP_OWNER),