|
@@ -495,16 +495,21 @@ public class LogAggregationIndexedFileController
|
|
boolean getAllContainers = (containerIdStr == null
|
|
boolean getAllContainers = (containerIdStr == null
|
|
|| containerIdStr.isEmpty());
|
|
|| containerIdStr.isEmpty());
|
|
long size = logRequest.getBytes();
|
|
long size = logRequest.getBytes();
|
|
- List<FileStatus> nodeFiles = LogAggregationUtils
|
|
|
|
- .getRemoteNodeFileList(conf, appId, logRequest.getAppOwner(),
|
|
|
|
|
|
+ RemoteIterator<FileStatus> nodeFiles = LogAggregationUtils
|
|
|
|
+ .getRemoteNodeFileDir(conf, appId, logRequest.getAppOwner(),
|
|
this.remoteRootLogDir, this.remoteRootLogDirSuffix);
|
|
this.remoteRootLogDir, this.remoteRootLogDirSuffix);
|
|
- if (nodeFiles.isEmpty()) {
|
|
|
|
|
|
+ if (!nodeFiles.hasNext()) {
|
|
throw new IOException("There is no available log fils for "
|
|
throw new IOException("There is no available log fils for "
|
|
+ "application:" + appId);
|
|
+ "application:" + appId);
|
|
}
|
|
}
|
|
- Map<String, Long> checkSumFiles = parseCheckSumFiles(nodeFiles);
|
|
|
|
|
|
+ List<FileStatus> allFiles = getAllNodeFiles(nodeFiles, appId);
|
|
|
|
+ if (allFiles.isEmpty()) {
|
|
|
|
+ throw new IOException("There is no available log fils for "
|
|
|
|
+ + "application:" + appId);
|
|
|
|
+ }
|
|
|
|
+ Map<String, Long> checkSumFiles = parseCheckSumFiles(allFiles);
|
|
List<FileStatus> fileToRead = getNodeLogFileToRead(
|
|
List<FileStatus> fileToRead = getNodeLogFileToRead(
|
|
- nodeFiles, nodeIdStr, appId);
|
|
|
|
|
|
+ allFiles, nodeIdStr, appId);
|
|
byte[] buf = new byte[65535];
|
|
byte[] buf = new byte[65535];
|
|
for (FileStatus thisNodeFile : fileToRead) {
|
|
for (FileStatus thisNodeFile : fileToRead) {
|
|
String nodeName = thisNodeFile.getPath().getName();
|
|
String nodeName = thisNodeFile.getPath().getName();
|
|
@@ -609,16 +614,21 @@ public class LogAggregationIndexedFileController
|
|
containerIdStr.isEmpty());
|
|
containerIdStr.isEmpty());
|
|
String nodeIdStr = (nodeId == null || nodeId.isEmpty()) ? null
|
|
String nodeIdStr = (nodeId == null || nodeId.isEmpty()) ? null
|
|
: LogAggregationUtils.getNodeString(nodeId);
|
|
: LogAggregationUtils.getNodeString(nodeId);
|
|
- List<FileStatus> nodeFiles = LogAggregationUtils
|
|
|
|
- .getRemoteNodeFileList(conf, appId, appOwner, this.remoteRootLogDir,
|
|
|
|
|
|
+ RemoteIterator<FileStatus> nodeFiles = LogAggregationUtils
|
|
|
|
+ .getRemoteNodeFileDir(conf, appId, appOwner, this.remoteRootLogDir,
|
|
this.remoteRootLogDirSuffix);
|
|
this.remoteRootLogDirSuffix);
|
|
- if (nodeFiles.isEmpty()) {
|
|
|
|
|
|
+ if (!nodeFiles.hasNext()) {
|
|
throw new IOException("There is no available log fils for "
|
|
throw new IOException("There is no available log fils for "
|
|
+ "application:" + appId);
|
|
+ "application:" + appId);
|
|
}
|
|
}
|
|
- Map<String, Long> checkSumFiles = parseCheckSumFiles(nodeFiles);
|
|
|
|
|
|
+ List<FileStatus> allFiles = getAllNodeFiles(nodeFiles, appId);
|
|
|
|
+ if (allFiles.isEmpty()) {
|
|
|
|
+ throw new IOException("There is no available log fils for "
|
|
|
|
+ + "application:" + appId);
|
|
|
|
+ }
|
|
|
|
+ Map<String, Long> checkSumFiles = parseCheckSumFiles(allFiles);
|
|
List<FileStatus> fileToRead = getNodeLogFileToRead(
|
|
List<FileStatus> fileToRead = getNodeLogFileToRead(
|
|
- nodeFiles, nodeIdStr, appId);
|
|
|
|
|
|
+ allFiles, nodeIdStr, appId);
|
|
for(FileStatus thisNodeFile : fileToRead) {
|
|
for(FileStatus thisNodeFile : fileToRead) {
|
|
try {
|
|
try {
|
|
Long checkSumIndex = checkSumFiles.get(
|
|
Long checkSumIndex = checkSumFiles.get(
|
|
@@ -727,21 +737,33 @@ public class LogAggregationIndexedFileController
|
|
List<FileStatus> nodeFiles, String nodeId, ApplicationId appId)
|
|
List<FileStatus> nodeFiles, String nodeId, ApplicationId appId)
|
|
throws IOException {
|
|
throws IOException {
|
|
List<FileStatus> listOfFiles = new ArrayList<>();
|
|
List<FileStatus> listOfFiles = new ArrayList<>();
|
|
- List<FileStatus> files = new ArrayList<>(nodeFiles);
|
|
|
|
- for (FileStatus file : files) {
|
|
|
|
- String nodeName = file.getPath().getName();
|
|
|
|
|
|
+ for (FileStatus thisNodeFile : nodeFiles) {
|
|
|
|
+ String nodeName = thisNodeFile.getPath().getName();
|
|
if ((nodeId == null || nodeId.isEmpty()
|
|
if ((nodeId == null || nodeId.isEmpty()
|
|
|| nodeName.contains(LogAggregationUtils
|
|
|| nodeName.contains(LogAggregationUtils
|
|
.getNodeString(nodeId))) && !nodeName.endsWith(
|
|
.getNodeString(nodeId))) && !nodeName.endsWith(
|
|
LogAggregationUtils.TMP_FILE_SUFFIX) &&
|
|
LogAggregationUtils.TMP_FILE_SUFFIX) &&
|
|
!nodeName.endsWith(CHECK_SUM_FILE_SUFFIX)) {
|
|
!nodeName.endsWith(CHECK_SUM_FILE_SUFFIX)) {
|
|
- if (nodeName.equals(appId + ".har")) {
|
|
|
|
- Path p = new Path("har:///" + file.getPath().toUri().getRawPath());
|
|
|
|
- files = Arrays.asList(HarFs.get(p.toUri(), conf).listStatus(p));
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- listOfFiles.add(file);
|
|
|
|
|
|
+ listOfFiles.add(thisNodeFile);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return listOfFiles;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<FileStatus> getAllNodeFiles(
|
|
|
|
+ RemoteIterator<FileStatus> nodeFiles, ApplicationId appId)
|
|
|
|
+ throws IOException {
|
|
|
|
+ List<FileStatus> listOfFiles = new ArrayList<>();
|
|
|
|
+ while (nodeFiles != null && nodeFiles.hasNext()) {
|
|
|
|
+ FileStatus thisNodeFile = nodeFiles.next();
|
|
|
|
+ String nodeName = thisNodeFile.getPath().getName();
|
|
|
|
+ if (nodeName.equals(appId + ".har")) {
|
|
|
|
+ Path p = new Path("har:///"
|
|
|
|
+ + thisNodeFile.getPath().toUri().getRawPath());
|
|
|
|
+ nodeFiles = HarFs.get(p.toUri(), conf).listStatusIterator(p);
|
|
|
|
+ continue;
|
|
}
|
|
}
|
|
|
|
+ listOfFiles.add(thisNodeFile);
|
|
}
|
|
}
|
|
return listOfFiles;
|
|
return listOfFiles;
|
|
}
|
|
}
|