YARN-5257. Fix unreleased resources and null dereferences (yufeigu via rkanter)
(cherry picked from commit 9262797e86
)
This commit is contained in:
parent
8fbd36c60f
commit
88597991b0
|
@ -192,11 +192,11 @@ public class UnmanagedAMLauncher {
|
|||
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 @@ public class TopCLI extends YarnCLI {
|
|||
|
||||
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 {
|
||||
|
|
|
@ -603,7 +603,7 @@ public class TimelineClientImpl extends TimelineClient {
|
|||
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 class Graph {
|
|||
|
||||
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 class VisualizeStateMachine {
|
|||
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 @@ public class ProcfsBasedProcessTree extends ResourceCalculatorProcessTree {
|
|||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("MemInfo : " + key + " : Value : " + value);
|
||||
}
|
||||
memoryMappingInfo.setMemInfo(key, value);
|
||||
|
||||
if (memoryMappingInfo != null) {
|
||||
memoryMappingInfo.setMemInfo(key, value);
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
LOG
|
||||
|
|
|
@ -533,7 +533,7 @@ public class ApplicationImpl implements Application {
|
|||
} 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);
|
||||
}
|
||||
|
|
|
@ -1643,7 +1643,7 @@ public class ContainerImpl implements Container {
|
|||
LOG.warn("Can't handle this event at current state: Current: ["
|
||||
+ oldState + "], eventType: [" + event.getType() + "]", e);
|
||||
}
|
||||
if (oldState != newState) {
|
||||
if (newState != null && oldState != newState) {
|
||||
LOG.info("Container " + containerID + " transitioned from "
|
||||
+ oldState
|
||||
+ " to " + newState);
|
||||
|
|
|
@ -626,15 +626,16 @@ import java.util.regex.Pattern;
|
|||
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 class LocalizedResource implements EventHandler<ResourceEvent> {
|
|||
} 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 @@ public class ResourceLocalizationService extends CompositeService
|
|||
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