YARN-6174. Log files pattern should be same for both running and finished container. Contributed by Xuan Gong.
This commit is contained in:
parent
859bd159ae
commit
ce2d5bfa5f
@ -0,0 +1,31 @@
|
|||||||
|
/**
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.apache.hadoop.yarn.logaggregation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enumeration of various aggregation type of a container log.
|
||||||
|
*/
|
||||||
|
public enum ContainerLogAggregationType {
|
||||||
|
|
||||||
|
/** The log is from NodeManager local log directory. */
|
||||||
|
LOCAL,
|
||||||
|
|
||||||
|
/** The log is from Remote FileSystem application log directory. */
|
||||||
|
AGGREGATED
|
||||||
|
}
|
@ -141,7 +141,7 @@ public static List<ContainerLogMeta> getContainerLogMetaFromRemoteFS(
|
|||||||
public static void outputContainerLog(String containerId, String nodeId,
|
public static void outputContainerLog(String containerId, String nodeId,
|
||||||
String fileName, long fileLength, long outputSize,
|
String fileName, long fileLength, long outputSize,
|
||||||
String lastModifiedTime, InputStream fis, OutputStream os,
|
String lastModifiedTime, InputStream fis, OutputStream os,
|
||||||
byte[] buf, ContainerLogType logType) throws IOException {
|
byte[] buf, ContainerLogAggregationType logType) throws IOException {
|
||||||
long toSkip = 0;
|
long toSkip = 0;
|
||||||
long totalBytesToRead = fileLength;
|
long totalBytesToRead = fileLength;
|
||||||
long skipAfterRead = 0;
|
long skipAfterRead = 0;
|
||||||
@ -171,9 +171,9 @@ public static void outputContainerLog(String containerId, String nodeId,
|
|||||||
LogToolUtils.CONTAINER_ON_NODE_PATTERN,
|
LogToolUtils.CONTAINER_ON_NODE_PATTERN,
|
||||||
containerId, nodeId);
|
containerId, nodeId);
|
||||||
sb.append(containerStr + "\n");
|
sb.append(containerStr + "\n");
|
||||||
sb.append("LogType: " + logType + "\n");
|
sb.append("LogAggregationType: " + logType + "\n");
|
||||||
sb.append(StringUtils.repeat("=", containerStr.length()) + "\n");
|
sb.append(StringUtils.repeat("=", containerStr.length()) + "\n");
|
||||||
sb.append("FileName:" + fileName + "\n");
|
sb.append("LogType:" + fileName + "\n");
|
||||||
sb.append("LogLastModifiedTime:" + lastModifiedTime + "\n");
|
sb.append("LogLastModifiedTime:" + lastModifiedTime + "\n");
|
||||||
sb.append("LogLength:" + Long.toString(fileLength) + "\n");
|
sb.append("LogLength:" + Long.toString(fileLength) + "\n");
|
||||||
sb.append("LogContents:\n");
|
sb.append("LogContents:\n");
|
||||||
@ -240,9 +240,10 @@ public static boolean outputAggregatedContainerLog(Configuration conf,
|
|||||||
LogToolUtils.outputContainerLog(containerId,
|
LogToolUtils.outputContainerLog(containerId,
|
||||||
nodeId, fileType, fileLength, outputSize,
|
nodeId, fileType, fileLength, outputSize,
|
||||||
Times.format(thisNodeFile.getModificationTime()),
|
Times.format(thisNodeFile.getModificationTime()),
|
||||||
valueStream, os, buf, ContainerLogType.AGGREGATED);
|
valueStream, os, buf,
|
||||||
|
ContainerLogAggregationType.AGGREGATED);
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
String endOfFile = "End of LogFile:" + fileType;
|
String endOfFile = "End of LogType:" + fileType;
|
||||||
sb.append("\n" + endOfFile + "\n");
|
sb.append("\n" + endOfFile + "\n");
|
||||||
sb.append(StringUtils.repeat("*", endOfFile.length() + 50)
|
sb.append(StringUtils.repeat("*", endOfFile.length() + 50)
|
||||||
+ "\n\n");
|
+ "\n\n");
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
import org.apache.hadoop.yarn.api.ApplicationBaseProtocol;
|
import org.apache.hadoop.yarn.api.ApplicationBaseProtocol;
|
||||||
import org.apache.hadoop.yarn.api.records.timeline.TimelineAbout;
|
import org.apache.hadoop.yarn.api.records.timeline.TimelineAbout;
|
||||||
import org.apache.hadoop.yarn.logaggregation.ContainerLogMeta;
|
import org.apache.hadoop.yarn.logaggregation.ContainerLogMeta;
|
||||||
import org.apache.hadoop.yarn.logaggregation.ContainerLogType;
|
import org.apache.hadoop.yarn.logaggregation.ContainerLogAggregationType;
|
||||||
import org.apache.hadoop.yarn.logaggregation.LogToolUtils;
|
import org.apache.hadoop.yarn.logaggregation.LogToolUtils;
|
||||||
import org.apache.hadoop.yarn.server.webapp.WebServices;
|
import org.apache.hadoop.yarn.server.webapp.WebServices;
|
||||||
import org.apache.hadoop.yarn.server.webapp.YarnWebServiceParams;
|
import org.apache.hadoop.yarn.server.webapp.YarnWebServiceParams;
|
||||||
@ -510,13 +510,14 @@ public void write(OutputStream os) throws IOException,
|
|||||||
boolean findLogs = LogToolUtils.outputAggregatedContainerLog(conf,
|
boolean findLogs = LogToolUtils.outputAggregatedContainerLog(conf,
|
||||||
appId, appOwner, containerIdStr, nodeId, logFile, bytes, os, buf);
|
appId, appOwner, containerIdStr, nodeId, logFile, bytes, os, buf);
|
||||||
if (!findLogs) {
|
if (!findLogs) {
|
||||||
throw new IOException("Can not find logs for container:"
|
os.write(("Can not find logs for container:"
|
||||||
+ containerIdStr);
|
+ containerIdStr).getBytes(Charset.forName("UTF-8")));
|
||||||
} else {
|
} else {
|
||||||
if (printEmptyLocalContainerLog) {
|
if (printEmptyLocalContainerLog) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append(containerIdStr + "\n");
|
sb.append(containerIdStr + "\n");
|
||||||
sb.append("LogType: " + ContainerLogType.LOCAL + "\n");
|
sb.append("LogAggregationType: "
|
||||||
|
+ ContainerLogAggregationType.LOCAL + "\n");
|
||||||
sb.append("LogContents:\n");
|
sb.append("LogContents:\n");
|
||||||
sb.append(getNoRedirectWarning() + "\n");
|
sb.append(getNoRedirectWarning() + "\n");
|
||||||
os.write(sb.toString().getBytes(Charset.forName("UTF-8")));
|
os.write(sb.toString().getBytes(Charset.forName("UTF-8")));
|
||||||
@ -548,14 +549,14 @@ private Response getContainerLogMeta(ApplicationId appId, String appOwner,
|
|||||||
List<ContainerLogsInfo> containersLogsInfo = new ArrayList<>();
|
List<ContainerLogsInfo> containersLogsInfo = new ArrayList<>();
|
||||||
for (ContainerLogMeta meta : containerLogMeta) {
|
for (ContainerLogMeta meta : containerLogMeta) {
|
||||||
ContainerLogsInfo logInfo = new ContainerLogsInfo(meta,
|
ContainerLogsInfo logInfo = new ContainerLogsInfo(meta,
|
||||||
ContainerLogType.AGGREGATED);
|
ContainerLogAggregationType.AGGREGATED);
|
||||||
containersLogsInfo.add(logInfo);
|
containersLogsInfo.add(logInfo);
|
||||||
}
|
}
|
||||||
if (emptyLocalContainerLogMeta) {
|
if (emptyLocalContainerLogMeta) {
|
||||||
ContainerLogMeta emptyMeta = new ContainerLogMeta(
|
ContainerLogMeta emptyMeta = new ContainerLogMeta(
|
||||||
containerIdStr, "N/A");
|
containerIdStr, "N/A");
|
||||||
ContainerLogsInfo empty = new ContainerLogsInfo(emptyMeta,
|
ContainerLogsInfo empty = new ContainerLogsInfo(emptyMeta,
|
||||||
ContainerLogType.LOCAL);
|
ContainerLogAggregationType.LOCAL);
|
||||||
containersLogsInfo.add(empty);
|
containersLogsInfo.add(empty);
|
||||||
}
|
}
|
||||||
GenericEntity<List<ContainerLogsInfo>> meta = new GenericEntity<List<
|
GenericEntity<List<ContainerLogsInfo>> meta = new GenericEntity<List<
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
import org.apache.hadoop.yarn.api.records.YarnApplicationAttemptState;
|
import org.apache.hadoop.yarn.api.records.YarnApplicationAttemptState;
|
||||||
import org.apache.hadoop.yarn.api.records.YarnApplicationState;
|
import org.apache.hadoop.yarn.api.records.YarnApplicationState;
|
||||||
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||||
import org.apache.hadoop.yarn.logaggregation.ContainerLogType;
|
import org.apache.hadoop.yarn.logaggregation.ContainerLogAggregationType;
|
||||||
import org.apache.hadoop.yarn.logaggregation.PerContainerLogFileInfo;
|
import org.apache.hadoop.yarn.logaggregation.PerContainerLogFileInfo;
|
||||||
import org.apache.hadoop.yarn.logaggregation.TestContainerLogsUtils;
|
import org.apache.hadoop.yarn.logaggregation.TestContainerLogsUtils;
|
||||||
import org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryClientService;
|
import org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryClientService;
|
||||||
@ -599,8 +599,8 @@ public void testContainerLogsForFinishedApps() throws Exception {
|
|||||||
assertTrue(responseText.contains("Hello." + containerId1ForApp100));
|
assertTrue(responseText.contains("Hello." + containerId1ForApp100));
|
||||||
int fullTextSize = responseText.getBytes().length;
|
int fullTextSize = responseText.getBytes().length;
|
||||||
String tailEndSeparator = StringUtils.repeat("*",
|
String tailEndSeparator = StringUtils.repeat("*",
|
||||||
"End of LogFile:syslog".length() + 50) + "\n\n";
|
"End of LogType:syslog".length() + 50) + "\n\n";
|
||||||
int tailTextSize = "\nEnd of LogFile:syslog\n".getBytes().length
|
int tailTextSize = "\nEnd of LogType:syslog\n".getBytes().length
|
||||||
+ tailEndSeparator.getBytes().length;
|
+ tailEndSeparator.getBytes().length;
|
||||||
|
|
||||||
String logMessage = "Hello." + containerId1ForApp100;
|
String logMessage = "Hello." + containerId1ForApp100;
|
||||||
@ -752,7 +752,8 @@ public void testContainerLogsForRunningApps() throws Exception {
|
|||||||
assertTrue(responseText.contains(content));
|
assertTrue(responseText.contains(content));
|
||||||
// Also test whether we output the empty local container log, and give
|
// Also test whether we output the empty local container log, and give
|
||||||
// the warning message.
|
// the warning message.
|
||||||
assertTrue(responseText.contains("LogType: " + ContainerLogType.LOCAL));
|
assertTrue(responseText.contains("LogAggregationType: "
|
||||||
|
+ ContainerLogAggregationType.LOCAL));
|
||||||
assertTrue(responseText.contains(AHSWebServices.getNoRedirectWarning()));
|
assertTrue(responseText.contains(AHSWebServices.getNoRedirectWarning()));
|
||||||
|
|
||||||
// If we can not container information from ATS, and we specify the NM id,
|
// If we can not container information from ATS, and we specify the NM id,
|
||||||
@ -767,7 +768,8 @@ public void testContainerLogsForRunningApps() throws Exception {
|
|||||||
.get(ClientResponse.class);
|
.get(ClientResponse.class);
|
||||||
responseText = response.getEntity(String.class);
|
responseText = response.getEntity(String.class);
|
||||||
assertTrue(responseText.contains(content));
|
assertTrue(responseText.contains(content));
|
||||||
assertTrue(responseText.contains("LogType: " + ContainerLogType.LOCAL));
|
assertTrue(responseText.contains("LogAggregationType: "
|
||||||
|
+ ContainerLogAggregationType.LOCAL));
|
||||||
assertTrue(responseText.contains(AHSWebServices.getNoRedirectWarning()));
|
assertTrue(responseText.contains(AHSWebServices.getNoRedirectWarning()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -830,7 +832,8 @@ public void testContainerLogsMetaForRunningApps() throws Exception {
|
|||||||
List<ContainerLogsInfo>>(){});
|
List<ContainerLogsInfo>>(){});
|
||||||
assertTrue(responseText.size() == 2);
|
assertTrue(responseText.size() == 2);
|
||||||
for (ContainerLogsInfo logInfo : responseText) {
|
for (ContainerLogsInfo logInfo : responseText) {
|
||||||
if(logInfo.getLogType().equals(ContainerLogType.AGGREGATED.toString())) {
|
if(logInfo.getLogType().equals(
|
||||||
|
ContainerLogAggregationType.AGGREGATED.toString())) {
|
||||||
List<PerContainerLogFileInfo> logMeta = logInfo
|
List<PerContainerLogFileInfo> logMeta = logInfo
|
||||||
.getContainerLogsInfo();
|
.getContainerLogsInfo();
|
||||||
assertTrue(logMeta.size() == 1);
|
assertTrue(logMeta.size() == 1);
|
||||||
@ -838,7 +841,8 @@ public void testContainerLogsMetaForRunningApps() throws Exception {
|
|||||||
assertEquals(logMeta.get(0).getFileSize(), String.valueOf(
|
assertEquals(logMeta.get(0).getFileSize(), String.valueOf(
|
||||||
content.length()));
|
content.length()));
|
||||||
} else {
|
} else {
|
||||||
assertEquals(logInfo.getLogType(), ContainerLogType.LOCAL.toString());
|
assertEquals(logInfo.getLogType(),
|
||||||
|
ContainerLogAggregationType.LOCAL.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -856,7 +860,8 @@ public void testContainerLogsMetaForRunningApps() throws Exception {
|
|||||||
List<ContainerLogsInfo>>(){});
|
List<ContainerLogsInfo>>(){});
|
||||||
assertTrue(responseText.size() == 2);
|
assertTrue(responseText.size() == 2);
|
||||||
for (ContainerLogsInfo logInfo : responseText) {
|
for (ContainerLogsInfo logInfo : responseText) {
|
||||||
if(logInfo.getLogType().equals(ContainerLogType.AGGREGATED.toString())) {
|
if(logInfo.getLogType().equals(
|
||||||
|
ContainerLogAggregationType.AGGREGATED.toString())) {
|
||||||
List<PerContainerLogFileInfo> logMeta = logInfo
|
List<PerContainerLogFileInfo> logMeta = logInfo
|
||||||
.getContainerLogsInfo();
|
.getContainerLogsInfo();
|
||||||
assertTrue(logMeta.size() == 1);
|
assertTrue(logMeta.size() == 1);
|
||||||
@ -864,7 +869,8 @@ public void testContainerLogsMetaForRunningApps() throws Exception {
|
|||||||
assertEquals(logMeta.get(0).getFileSize(), String.valueOf(
|
assertEquals(logMeta.get(0).getFileSize(), String.valueOf(
|
||||||
content.length()));
|
content.length()));
|
||||||
} else {
|
} else {
|
||||||
assertEquals(logInfo.getLogType(), ContainerLogType.LOCAL.toString());
|
assertEquals(logInfo.getLogType(),
|
||||||
|
ContainerLogAggregationType.LOCAL.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -893,7 +899,7 @@ public void testContainerLogsMetaForFinishedApps() throws Exception {
|
|||||||
List<ContainerLogsInfo>>(){});
|
List<ContainerLogsInfo>>(){});
|
||||||
assertTrue(responseText.size() == 1);
|
assertTrue(responseText.size() == 1);
|
||||||
assertEquals(responseText.get(0).getLogType(),
|
assertEquals(responseText.get(0).getLogType(),
|
||||||
ContainerLogType.AGGREGATED.toString());
|
ContainerLogAggregationType.AGGREGATED.toString());
|
||||||
List<PerContainerLogFileInfo> logMeta = responseText.get(0)
|
List<PerContainerLogFileInfo> logMeta = responseText.get(0)
|
||||||
.getContainerLogsInfo();
|
.getContainerLogsInfo();
|
||||||
assertTrue(logMeta.size() == 1);
|
assertTrue(logMeta.size() == 1);
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
import org.apache.hadoop.yarn.exceptions.YarnException;
|
import org.apache.hadoop.yarn.exceptions.YarnException;
|
||||||
import org.apache.hadoop.yarn.logaggregation.ContainerLogMeta;
|
import org.apache.hadoop.yarn.logaggregation.ContainerLogMeta;
|
||||||
import org.apache.hadoop.yarn.logaggregation.ContainerLogType;
|
import org.apache.hadoop.yarn.logaggregation.ContainerLogAggregationType;
|
||||||
import org.apache.hadoop.yarn.logaggregation.PerContainerLogFileInfo;
|
import org.apache.hadoop.yarn.logaggregation.PerContainerLogFileInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,7 +48,7 @@ public class ContainerLogsInfo {
|
|||||||
@XmlElement(name = "containerLogInfo")
|
@XmlElement(name = "containerLogInfo")
|
||||||
protected List<PerContainerLogFileInfo> containerLogsInfo;
|
protected List<PerContainerLogFileInfo> containerLogsInfo;
|
||||||
|
|
||||||
@XmlElement(name = "logType")
|
@XmlElement(name = "logAggregationType")
|
||||||
protected String logType;
|
protected String logType;
|
||||||
|
|
||||||
@XmlElement(name = "containerId")
|
@XmlElement(name = "containerId")
|
||||||
@ -60,8 +60,8 @@ public class ContainerLogsInfo {
|
|||||||
//JAXB needs this
|
//JAXB needs this
|
||||||
public ContainerLogsInfo() {}
|
public ContainerLogsInfo() {}
|
||||||
|
|
||||||
public ContainerLogsInfo(ContainerLogMeta logMeta, ContainerLogType logType)
|
public ContainerLogsInfo(ContainerLogMeta logMeta,
|
||||||
throws YarnException {
|
ContainerLogAggregationType logType) throws YarnException {
|
||||||
this.containerLogsInfo = new ArrayList<PerContainerLogFileInfo>(
|
this.containerLogsInfo = new ArrayList<PerContainerLogFileInfo>(
|
||||||
logMeta.getContainerLogMeta());
|
logMeta.getContainerLogMeta());
|
||||||
this.logType = logType.toString();
|
this.logType = logType.toString();
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
import org.apache.hadoop.yarn.factories.RecordFactory;
|
import org.apache.hadoop.yarn.factories.RecordFactory;
|
||||||
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
|
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
|
||||||
import org.apache.hadoop.yarn.logaggregation.ContainerLogMeta;
|
import org.apache.hadoop.yarn.logaggregation.ContainerLogMeta;
|
||||||
import org.apache.hadoop.yarn.logaggregation.ContainerLogType;
|
import org.apache.hadoop.yarn.logaggregation.ContainerLogAggregationType;
|
||||||
import org.apache.hadoop.yarn.logaggregation.LogToolUtils;
|
import org.apache.hadoop.yarn.logaggregation.LogToolUtils;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.Context;
|
import org.apache.hadoop.yarn.server.nodemanager.Context;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.ResourceView;
|
import org.apache.hadoop.yarn.server.nodemanager.ResourceView;
|
||||||
@ -253,7 +253,7 @@ public Response getContainerLogsInfo(
|
|||||||
List<ContainerLogsInfo> containersLogsInfo = new ArrayList<>();
|
List<ContainerLogsInfo> containersLogsInfo = new ArrayList<>();
|
||||||
containersLogsInfo.add(new NMContainerLogsInfo(
|
containersLogsInfo.add(new NMContainerLogsInfo(
|
||||||
this.nmContext, containerId,
|
this.nmContext, containerId,
|
||||||
hsr.getRemoteUser(), ContainerLogType.LOCAL));
|
hsr.getRemoteUser(), ContainerLogAggregationType.LOCAL));
|
||||||
// check whether we have aggregated logs in RemoteFS. If exists, show the
|
// check whether we have aggregated logs in RemoteFS. If exists, show the
|
||||||
// the log meta for the aggregated logs as well.
|
// the log meta for the aggregated logs as well.
|
||||||
ApplicationId appId = containerId.getApplicationAttemptId()
|
ApplicationId appId = containerId.getApplicationAttemptId()
|
||||||
@ -268,7 +268,7 @@ public Response getContainerLogsInfo(
|
|||||||
if (!containerLogMeta.isEmpty()) {
|
if (!containerLogMeta.isEmpty()) {
|
||||||
for (ContainerLogMeta logMeta : containerLogMeta) {
|
for (ContainerLogMeta logMeta : containerLogMeta) {
|
||||||
containersLogsInfo.add(new ContainerLogsInfo(logMeta,
|
containersLogsInfo.add(new ContainerLogsInfo(logMeta,
|
||||||
ContainerLogType.AGGREGATED));
|
ContainerLogAggregationType.AGGREGATED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
@ -429,9 +429,10 @@ public void write(OutputStream os) throws IOException,
|
|||||||
byte[] buf = new byte[bufferSize];
|
byte[] buf = new byte[bufferSize];
|
||||||
LogToolUtils.outputContainerLog(containerId.toString(),
|
LogToolUtils.outputContainerLog(containerId.toString(),
|
||||||
nmContext.getNodeId().toString(), outputFileName, fileLength,
|
nmContext.getNodeId().toString(), outputFileName, fileLength,
|
||||||
bytes, lastModifiedTime, fis, os, buf, ContainerLogType.LOCAL);
|
bytes, lastModifiedTime, fis, os, buf,
|
||||||
|
ContainerLogAggregationType.LOCAL);
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
String endOfFile = "End of LogFile:" + outputFileName;
|
String endOfFile = "End of LogType:" + outputFileName;
|
||||||
sb.append(endOfFile + ".");
|
sb.append(endOfFile + ".");
|
||||||
if (isRunning) {
|
if (isRunning) {
|
||||||
sb.append("This log file belongs to a running container ("
|
sb.append("This log file belongs to a running container ("
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
import org.apache.hadoop.yarn.api.records.ContainerId;
|
import org.apache.hadoop.yarn.api.records.ContainerId;
|
||||||
import org.apache.hadoop.yarn.exceptions.YarnException;
|
import org.apache.hadoop.yarn.exceptions.YarnException;
|
||||||
import org.apache.hadoop.yarn.logaggregation.ContainerLogType;
|
import org.apache.hadoop.yarn.logaggregation.ContainerLogAggregationType;
|
||||||
import org.apache.hadoop.yarn.logaggregation.PerContainerLogFileInfo;
|
import org.apache.hadoop.yarn.logaggregation.PerContainerLogFileInfo;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.Context;
|
import org.apache.hadoop.yarn.server.nodemanager.Context;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.webapp.ContainerLogsUtils;
|
import org.apache.hadoop.yarn.server.nodemanager.webapp.ContainerLogsUtils;
|
||||||
@ -47,7 +47,7 @@ public NMContainerLogsInfo() {}
|
|||||||
|
|
||||||
public NMContainerLogsInfo(final Context nmContext,
|
public NMContainerLogsInfo(final Context nmContext,
|
||||||
final ContainerId containerId, String remoteUser,
|
final ContainerId containerId, String remoteUser,
|
||||||
ContainerLogType logType) throws YarnException {
|
ContainerLogAggregationType logType) throws YarnException {
|
||||||
this.logType = logType.toString();
|
this.logType = logType.toString();
|
||||||
this.containerId = containerId.toString();
|
this.containerId = containerId.toString();
|
||||||
this.nodeId = nmContext.getNodeId().toString();
|
this.nodeId = nmContext.getNodeId().toString();
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
import org.apache.hadoop.yarn.api.records.NodeId;
|
import org.apache.hadoop.yarn.api.records.NodeId;
|
||||||
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||||
import org.apache.hadoop.yarn.event.AsyncDispatcher;
|
import org.apache.hadoop.yarn.event.AsyncDispatcher;
|
||||||
import org.apache.hadoop.yarn.logaggregation.ContainerLogType;
|
import org.apache.hadoop.yarn.logaggregation.ContainerLogAggregationType;
|
||||||
import org.apache.hadoop.yarn.logaggregation.PerContainerLogFileInfo;
|
import org.apache.hadoop.yarn.logaggregation.PerContainerLogFileInfo;
|
||||||
import org.apache.hadoop.yarn.logaggregation.TestContainerLogsUtils;
|
import org.apache.hadoop.yarn.logaggregation.TestContainerLogsUtils;
|
||||||
import org.apache.hadoop.yarn.server.nodemanager.Context;
|
import org.apache.hadoop.yarn.server.nodemanager.Context;
|
||||||
@ -530,7 +530,7 @@ private void testContainerLogs(WebResource r, ContainerId containerId)
|
|||||||
List<ContainerLogsInfo>>(){});
|
List<ContainerLogsInfo>>(){});
|
||||||
assertTrue(responseList.size() == 1);
|
assertTrue(responseList.size() == 1);
|
||||||
assertEquals(responseList.get(0).getLogType(),
|
assertEquals(responseList.get(0).getLogType(),
|
||||||
ContainerLogType.LOCAL.toString());
|
ContainerLogAggregationType.LOCAL.toString());
|
||||||
List<PerContainerLogFileInfo> logMeta = responseList.get(0)
|
List<PerContainerLogFileInfo> logMeta = responseList.get(0)
|
||||||
.getContainerLogsInfo();
|
.getContainerLogsInfo();
|
||||||
assertTrue(logMeta.size() == 1);
|
assertTrue(logMeta.size() == 1);
|
||||||
@ -557,12 +557,13 @@ private void testContainerLogs(WebResource r, ContainerId containerId)
|
|||||||
assertEquals(responseList.size(), 2);
|
assertEquals(responseList.size(), 2);
|
||||||
for (ContainerLogsInfo logInfo : responseList) {
|
for (ContainerLogsInfo logInfo : responseList) {
|
||||||
if(logInfo.getLogType().equals(
|
if(logInfo.getLogType().equals(
|
||||||
ContainerLogType.AGGREGATED.toString())) {
|
ContainerLogAggregationType.AGGREGATED.toString())) {
|
||||||
List<PerContainerLogFileInfo> meta = logInfo.getContainerLogsInfo();
|
List<PerContainerLogFileInfo> meta = logInfo.getContainerLogsInfo();
|
||||||
assertTrue(meta.size() == 1);
|
assertTrue(meta.size() == 1);
|
||||||
assertEquals(meta.get(0).getFileName(), aggregatedLogFile);
|
assertEquals(meta.get(0).getFileName(), aggregatedLogFile);
|
||||||
} else {
|
} else {
|
||||||
assertEquals(logInfo.getLogType(), ContainerLogType.LOCAL.toString());
|
assertEquals(logInfo.getLogType(),
|
||||||
|
ContainerLogAggregationType.LOCAL.toString());
|
||||||
List<PerContainerLogFileInfo> meta = logInfo.getContainerLogsInfo();
|
List<PerContainerLogFileInfo> meta = logInfo.getContainerLogsInfo();
|
||||||
assertTrue(meta.size() == 1);
|
assertTrue(meta.size() == 1);
|
||||||
assertEquals(meta.get(0).getFileName(), filename);
|
assertEquals(meta.get(0).getFileName(), filename);
|
||||||
@ -577,11 +578,11 @@ private void testContainerLogs(WebResource r, ContainerId containerId)
|
|||||||
response = r.path(filename)
|
response = r.path(filename)
|
||||||
.accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
|
.accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
|
||||||
responseText = response.getEntity(String.class);
|
responseText = response.getEntity(String.class);
|
||||||
assertTrue(responseText.contains("LogType: "
|
assertTrue(responseText.contains("LogAggregationType: "
|
||||||
+ ContainerLogType.AGGREGATED));
|
+ ContainerLogAggregationType.AGGREGATED));
|
||||||
assertTrue(responseText.contains(aggregatedLogMessage));
|
assertTrue(responseText.contains(aggregatedLogMessage));
|
||||||
assertTrue(responseText.contains("LogType: "
|
assertTrue(responseText.contains("LogAggregationType: "
|
||||||
+ ContainerLogType.LOCAL));
|
+ ContainerLogAggregationType.LOCAL));
|
||||||
assertTrue(responseText.contains(logMessage));
|
assertTrue(responseText.contains(logMessage));
|
||||||
} finally {
|
} finally {
|
||||||
FileUtil.fullyDelete(tempLogDir);
|
FileUtil.fullyDelete(tempLogDir);
|
||||||
@ -685,7 +686,7 @@ public void verifyNodeInfoGeneric(String id, String healthReport,
|
|||||||
|
|
||||||
private String getLogContext(String fullMessage) {
|
private String getLogContext(String fullMessage) {
|
||||||
String prefix = "LogContents:\n";
|
String prefix = "LogContents:\n";
|
||||||
String postfix = "End of LogFile:";
|
String postfix = "End of LogType:";
|
||||||
int prefixIndex = fullMessage.indexOf(prefix) + prefix.length();
|
int prefixIndex = fullMessage.indexOf(prefix) + prefix.length();
|
||||||
int postfixIndex = fullMessage.indexOf(postfix);
|
int postfixIndex = fullMessage.indexOf(postfix);
|
||||||
return fullMessage.substring(prefixIndex, postfixIndex);
|
return fullMessage.substring(prefixIndex, postfixIndex);
|
||||||
|
Loading…
Reference in New Issue
Block a user