YARN-6520. Fix warnings from Spotbugs in hadoop-yarn-client. Contributed by Weiwei Yang.

This commit is contained in:
Naganarasimha 2017-05-01 18:38:22 +05:30
parent 0f1af3178e
commit 64f68cb0b8
2 changed files with 31 additions and 37 deletions

View File

@ -367,9 +367,13 @@ private void addTimelineDelegationToken(
if (timelineClient == null) {
synchronized (this) {
if (timelineClient == null) {
timelineClient = createTimelineClient();
timelineClient.init(getConfig());
timelineClient.start();
TimelineClient tlClient = createTimelineClient();
tlClient.init(getConfig());
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;
}
}
}

View File

@ -963,10 +963,6 @@ private int fetchContainerLogs(ContainerLogsRequest request,
request.setNodeId(nodeId);
request.setContainerState(report.getContainerState());
} catch (IOException | YarnException ex) {
if (isAppFinished) {
return printContainerLogsForFinishedApplicationWithoutNodeId(
request, logCliHelper, useRegex);
} else {
nodeHttpAddress = getNodeHttpAddressFromRMWebString(request);
if (nodeHttpAddress != null && !nodeHttpAddress.isEmpty()) {
request.setNodeHttpAddress(nodeHttpAddress);
@ -974,16 +970,18 @@ private int fetchContainerLogs(ContainerLogsRequest request,
// for the case, we have already uploaded partial logs in HDFS
int result = -1;
if (nodeAddress != null && !nodeAddress.isEmpty()) {
result = printAggregatedContainerLogs(
request, logCliHelper, useRegex);
result = printAggregatedContainerLogs(request,
logCliHelper, useRegex);
} else {
result = printAggregatedContainerLogsWithoutNodeId(
request, logCliHelper, useRegex);
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(
"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 "
@ -992,19 +990,11 @@ private int fetchContainerLogs(ContainerLogsRequest request,
return result;
}
}
}
// If the application is not in the final state,
// we will provide the NodeHttpAddress and get the container logs
// by calling NodeManager webservice.
if (!isAppFinished) {
resultCode = printContainerLogsFromRunningApplication(getConf(), request,
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;
}