|
@@ -87,6 +87,7 @@ import org.apache.hadoop.yarn.logaggregation.ContainerLogsRequest;
|
|
|
import org.apache.hadoop.yarn.logaggregation.LogCLIHelpers;
|
|
|
import org.apache.hadoop.yarn.logaggregation.LogToolUtils;
|
|
|
import org.apache.hadoop.yarn.server.metrics.AppAttemptMetricsConstants;
|
|
|
+import org.apache.hadoop.yarn.util.Apps;
|
|
|
import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
|
|
|
import org.apache.hadoop.yarn.webapp.util.YarnWebServiceUtils;
|
|
|
import org.codehaus.jettison.json.JSONArray;
|
|
@@ -356,8 +357,8 @@ public class LogsCLI extends Configured implements Tool {
|
|
|
|
|
|
|
|
|
ContainerLogsRequest request = new ContainerLogsRequest(appId,
|
|
|
- isApplicationFinished(appState), appOwner, nodeAddress, null,
|
|
|
- containerIdStr, localDir, logs, bytes, null);
|
|
|
+ Apps.isApplicationFinalState(appState), appOwner, nodeAddress,
|
|
|
+ null, containerIdStr, localDir, logs, bytes, null);
|
|
|
|
|
|
if (showContainerLogInfo) {
|
|
|
return showContainerLogInfo(request, logCliHelper);
|
|
@@ -597,7 +598,7 @@ public class LogsCLI extends Configured implements Tool {
|
|
|
for (String logFile : request.getLogTypes()) {
|
|
|
InputStream is = null;
|
|
|
try {
|
|
|
- ClientResponse response = getResponeFromNMWebService(conf,
|
|
|
+ ClientResponse response = getResponseFromNMWebService(conf,
|
|
|
webServiceClient, request, logFile);
|
|
|
if (response != null && response.getStatusInfo().getStatusCode() ==
|
|
|
ClientResponse.Status.OK.getStatusCode()) {
|
|
@@ -645,12 +646,6 @@ public class LogsCLI extends Configured implements Tool {
|
|
|
ContainerId.fromString(containerIdStr));
|
|
|
}
|
|
|
|
|
|
- private boolean isApplicationFinished(YarnApplicationState appState) {
|
|
|
- return appState == YarnApplicationState.FINISHED
|
|
|
- || appState == YarnApplicationState.FAILED
|
|
|
- || appState == YarnApplicationState.KILLED;
|
|
|
- }
|
|
|
-
|
|
|
private int printAMContainerLogs(Configuration conf,
|
|
|
ContainerLogsRequest request, List<String> amContainers,
|
|
|
LogCLIHelpers logCliHelper, boolean useRegex, boolean ignoreSizeLimit)
|
|
@@ -1462,16 +1457,10 @@ public class LogsCLI extends Configured implements Tool {
|
|
|
}
|
|
|
|
|
|
@VisibleForTesting
|
|
|
- public ClientResponse getResponeFromNMWebService(Configuration conf,
|
|
|
+ public ClientResponse getResponseFromNMWebService(Configuration conf,
|
|
|
Client webServiceClient, ContainerLogsRequest request, String logFile) {
|
|
|
- WebResource webResource =
|
|
|
- webServiceClient.resource(WebAppUtils.getHttpSchemePrefix(conf)
|
|
|
- + request.getNodeHttpAddress());
|
|
|
- return webResource.path("ws").path("v1").path("node")
|
|
|
- .path("containers").path(request.getContainerId()).path("logs")
|
|
|
- .path(logFile)
|
|
|
- .queryParam("size", Long.toString(request.getBytes()))
|
|
|
- .accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
|
|
|
+ return LogToolUtils.getResponseFromNMWebService(
|
|
|
+ conf, webServiceClient, request, logFile);
|
|
|
}
|
|
|
|
|
|
@VisibleForTesting
|