YARN-5257. Fix unreleased resources and null dereferences (yufeigu via rkanter)
This commit is contained in:
parent
1bbd023275
commit
9262797e86
@ -192,11 +192,11 @@ public void launchAM(ApplicationAttemptId attemptId)
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
tokenFile.deleteOnExit();
|
||||
DataOutputStream os = new DataOutputStream(new FileOutputStream(tokenFile,
|
||||
true));
|
||||
credentials.writeTokenStorageToStream(os);
|
||||
os.close();
|
||||
|
||||
try (DataOutputStream os = new DataOutputStream(
|
||||
new FileOutputStream(tokenFile, true))) {
|
||||
credentials.writeTokenStorageToStream(os);
|
||||
}
|
||||
|
||||
Map<String, String> env = System.getenv();
|
||||
ArrayList<String> envAMList = new ArrayList<String>();
|
||||
boolean setClasspath = false;
|
||||
|
@ -774,13 +774,14 @@ long getRMStartTime() {
|
||||
|
||||
private JSONObject getJSONObject(URLConnection conn)
|
||||
throws IOException, JSONException {
|
||||
InputStream in = conn.getInputStream();
|
||||
String encoding = conn.getContentEncoding();
|
||||
encoding = encoding == null ? "UTF-8" : encoding;
|
||||
String body = IOUtils.toString(in, encoding);
|
||||
JSONObject obj = new JSONObject(body);
|
||||
JSONObject clusterInfo = obj.getJSONObject("clusterInfo");
|
||||
return clusterInfo;
|
||||
try(InputStream in = conn.getInputStream()) {
|
||||
String encoding = conn.getContentEncoding();
|
||||
encoding = encoding == null ? "UTF-8" : encoding;
|
||||
String body = IOUtils.toString(in, encoding);
|
||||
JSONObject obj = new JSONObject(body);
|
||||
JSONObject clusterInfo = obj.getJSONObject("clusterInfo");
|
||||
return clusterInfo;
|
||||
}
|
||||
}
|
||||
|
||||
private URL getClusterUrl() throws Exception {
|
||||
|
@ -805,7 +805,7 @@ private static void putTimelineDataInJSONFile(String path, String type) {
|
||||
error.getErrorCode());
|
||||
}
|
||||
}
|
||||
} else if (type.equals(DOMAIN_DATA_TYPE)) {
|
||||
} else if (type.equals(DOMAIN_DATA_TYPE) && domains != null) {
|
||||
boolean hasError = false;
|
||||
for (TimelineDomain domain : domains.getDomains()) {
|
||||
try {
|
||||
|
@ -189,7 +189,7 @@ public String generateGraphViz() {
|
||||
|
||||
public void save(String filepath) throws IOException {
|
||||
try (OutputStreamWriter fout = new OutputStreamWriter(
|
||||
new FileOutputStream(filepath), Charset.forName("UTF-8"));) {
|
||||
new FileOutputStream(filepath), Charset.forName("UTF-8"))) {
|
||||
fout.write(generateGraphViz());
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,9 @@ public static Graph getGraphFromClasses(String graphName, List<String> classes)
|
||||
if (gname.endsWith("Impl")) {
|
||||
gname = gname.substring(0, gname.length()-4);
|
||||
}
|
||||
ret.addSubGraph(factory.generateStateGraph(gname));
|
||||
if (ret != null) {
|
||||
ret.addSubGraph(factory.generateStateGraph(gname));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -803,7 +803,10 @@ private static void constructProcessSMAPInfo(ProcessTreeSmapMemInfo pInfo,
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("MemInfo : " + key + " : Value : " + value);
|
||||
}
|
||||
memoryMappingInfo.setMemInfo(key, value);
|
||||
|
||||
if (memoryMappingInfo != null) {
|
||||
memoryMappingInfo.setMemInfo(key, value);
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
LOG
|
||||
|
@ -603,7 +603,7 @@ public void handle(ApplicationEvent event) {
|
||||
} catch (InvalidStateTransitionException e) {
|
||||
LOG.warn("Can't handle this event at current state", e);
|
||||
}
|
||||
if (oldState != newState) {
|
||||
if (newState != null && oldState != newState) {
|
||||
LOG.info("Application " + applicationID + " transitioned from "
|
||||
+ oldState + " to " + newState);
|
||||
}
|
||||
|
@ -1680,7 +1680,7 @@ public void handle(ContainerEvent event) {
|
||||
+ oldState + "], eventType: [" + event.getType() + "]," +
|
||||
" container: [" + containerID + "]", e);
|
||||
}
|
||||
if (oldState != newState) {
|
||||
if (newState != null && oldState != newState) {
|
||||
LOG.info("Container " + containerID + " transitioned from "
|
||||
+ oldState
|
||||
+ " to " + newState);
|
||||
|
@ -626,15 +626,16 @@ public PrivilegedOperation commitBatchToTempFile()
|
||||
try {
|
||||
File tcCmds = File.createTempFile(TMP_FILE_PREFIX, TMP_FILE_SUFFIX, new
|
||||
File(tmpDirPath));
|
||||
Writer writer = new OutputStreamWriter(new FileOutputStream(tcCmds),
|
||||
"UTF-8");
|
||||
PrintWriter printWriter = new PrintWriter(writer);
|
||||
|
||||
for (String command : commands) {
|
||||
printWriter.println(command);
|
||||
try (
|
||||
Writer writer = new OutputStreamWriter(new FileOutputStream(tcCmds),
|
||||
"UTF-8");
|
||||
PrintWriter printWriter = new PrintWriter(writer)) {
|
||||
for (String command : commands) {
|
||||
printWriter.println(command);
|
||||
}
|
||||
}
|
||||
|
||||
printWriter.close();
|
||||
operation.appendArgs(tcCmds.getAbsolutePath());
|
||||
|
||||
return operation;
|
||||
|
@ -200,7 +200,7 @@ public void handle(ResourceEvent event) {
|
||||
} catch (InvalidStateTransitionException e) {
|
||||
LOG.warn("Can't handle this event at current state", e);
|
||||
}
|
||||
if (oldState != newState) {
|
||||
if (newState != null && oldState != newState) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Resource " + resourcePath + (localPath != null ?
|
||||
"(->" + localPath + ")": "") + " transitioned from " + oldState
|
||||
|
@ -1051,6 +1051,7 @@ LocalizerHeartbeatResponse processHeartbeat(
|
||||
LOG.error(
|
||||
"Got exception in parsing URL of LocalResource:"
|
||||
+ rsrc.getResource(), e);
|
||||
continue;
|
||||
}
|
||||
LocalizerResourceRequestEvent assoc = scheduled.get(req);
|
||||
if (assoc == null) {
|
||||
|
Loading…
Reference in New Issue
Block a user