YARN-6520. Fix warnings from Spotbugs in hadoop-yarn-client. Contributed by Weiwei Yang.
This commit is contained in:
parent
0f1af3178e
commit
64f68cb0b8
@ -367,9 +367,13 @@ private void addTimelineDelegationToken(
|
|||||||
if (timelineClient == null) {
|
if (timelineClient == null) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (timelineClient == null) {
|
if (timelineClient == null) {
|
||||||
timelineClient = createTimelineClient();
|
TimelineClient tlClient = createTimelineClient();
|
||||||
timelineClient.init(getConfig());
|
tlClient.init(getConfig());
|
||||||
timelineClient.start();
|
tlClient.start();
|
||||||
|
// Assign value to timeline client variable only
|
||||||
|
// when it is fully initiated. In order to avoid
|
||||||
|
// other threads to see partially initialized object.
|
||||||
|
this.timelineClient = tlClient;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -963,48 +963,38 @@ private int fetchContainerLogs(ContainerLogsRequest request,
|
|||||||
request.setNodeId(nodeId);
|
request.setNodeId(nodeId);
|
||||||
request.setContainerState(report.getContainerState());
|
request.setContainerState(report.getContainerState());
|
||||||
} catch (IOException | YarnException ex) {
|
} catch (IOException | YarnException ex) {
|
||||||
if (isAppFinished) {
|
nodeHttpAddress = getNodeHttpAddressFromRMWebString(request);
|
||||||
return printContainerLogsForFinishedApplicationWithoutNodeId(
|
if (nodeHttpAddress != null && !nodeHttpAddress.isEmpty()) {
|
||||||
request, logCliHelper, useRegex);
|
request.setNodeHttpAddress(nodeHttpAddress);
|
||||||
} else {
|
} else {
|
||||||
nodeHttpAddress = getNodeHttpAddressFromRMWebString(request);
|
// for the case, we have already uploaded partial logs in HDFS
|
||||||
if (nodeHttpAddress != null && !nodeHttpAddress.isEmpty()) {
|
int result = -1;
|
||||||
request.setNodeHttpAddress(nodeHttpAddress);
|
if (nodeAddress != null && !nodeAddress.isEmpty()) {
|
||||||
|
result = printAggregatedContainerLogs(request,
|
||||||
|
logCliHelper, useRegex);
|
||||||
} else {
|
} else {
|
||||||
// for the case, we have already uploaded partial logs in HDFS
|
result = printAggregatedContainerLogsWithoutNodeId(request,
|
||||||
int result = -1;
|
logCliHelper,
|
||||||
if (nodeAddress != null && !nodeAddress.isEmpty()) {
|
useRegex);
|
||||||
result = printAggregatedContainerLogs(
|
|
||||||
request, logCliHelper, useRegex);
|
|
||||||
} else {
|
|
||||||
result = printAggregatedContainerLogsWithoutNodeId(
|
|
||||||
request, logCliHelper, useRegex);
|
|
||||||
}
|
|
||||||
if (result == -1) {
|
|
||||||
System.err.println("Unable to get logs for this container:"
|
|
||||||
+ containerIdStr + " for the application:" + appIdStr
|
|
||||||
+ " with the appOwner: " + appOwner);
|
|
||||||
System.err.println("The application: " + appIdStr
|
|
||||||
+ " is still running, and we can not get Container report "
|
|
||||||
+ "for the container: " + containerIdStr +". Please try later "
|
|
||||||
+ "or after the application finishes.");
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
if (result == -1) {
|
||||||
|
System.err.println(
|
||||||
|
"Unable to get logs for this container:"
|
||||||
|
+ containerIdStr + " for the application:"
|
||||||
|
+ appIdStr + " with the appOwner: " + appOwner);
|
||||||
|
System.err.println("The application: " + appIdStr
|
||||||
|
+ " is still running, and we can not get Container report "
|
||||||
|
+ "for the container: " + containerIdStr + ". Please try later "
|
||||||
|
+ "or after the application finishes.");
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If the application is not in the final state,
|
// If the application is not in the final state,
|
||||||
// we will provide the NodeHttpAddress and get the container logs
|
// we will provide the NodeHttpAddress and get the container logs
|
||||||
// by calling NodeManager webservice.
|
// by calling NodeManager webservice.
|
||||||
if (!isAppFinished) {
|
resultCode = printContainerLogsFromRunningApplication(getConf(), request,
|
||||||
resultCode = printContainerLogsFromRunningApplication(getConf(), request,
|
logCliHelper, useRegex);
|
||||||
logCliHelper, useRegex);
|
|
||||||
} else {
|
|
||||||
// If the application is in the final state, we will directly
|
|
||||||
// get the container logs from HDFS.
|
|
||||||
resultCode = printContainerLogsForFinishedApplication(
|
|
||||||
request, logCliHelper, useRegex);
|
|
||||||
}
|
|
||||||
return resultCode;
|
return resultCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user