YARN-10194. YARN RMWebServices /scheduler-conf/validate leaks ZK Connections. Contributed by Prabhu Joseph

(cherry picked from commit f91e21ac10)
This commit is contained in:
Szilard Nemeth 2020-04-27 08:26:11 +02:00
parent 9e79cca171
commit c0b7b38e22
5 changed files with 27 additions and 8 deletions

View File

@ -42,14 +42,18 @@ private CapacitySchedulerConfigValidator() {
public static boolean validateCSConfiguration(
final Configuration oldConf, final Configuration newConf,
final RMContext rmContext) throws IOException {
CapacityScheduler newCs = new CapacityScheduler();
try {
//TODO: extract all the validation steps and replace reinitialize with
//the specific validation steps
CapacityScheduler newCs = new CapacityScheduler();
newCs.setConf(oldConf);
newCs.setRMContext(rmContext);
newCs.init(oldConf);
newCs.reinitialize(newConf, rmContext, true);
return true;
} finally {
newCs.stop();
}
}
public static Set<String> validatePlacementRules(

View File

@ -358,6 +358,7 @@ protected Version getCurrentVersion() {
return CURRENT_VERSION_INFO;
}
@Override
public void close() throws IOException {
if (fileSystem != null) {
fileSystem.close();

View File

@ -22,6 +22,7 @@
import org.apache.hadoop.yarn.server.records.Version;
import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@ -150,4 +151,9 @@ public Version getCurrentVersion() {
public void checkVersion() {
// Does nothing. (Version is always compatible since it's in memory)
}
@Override
public void close() throws IOException {
// Does nothing.
}
}

View File

@ -99,7 +99,7 @@ public abstract void initialize(Configuration conf, Configuration schedConf,
* Closes the configuration store, releasing any required resources.
* @throws IOException on failure to close
*/
public void close() throws IOException {}
public abstract void close() throws IOException;
/**
* Logs the configuration change to backing store.

View File

@ -31,6 +31,7 @@
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.data.ACL;
import java.io.IOException;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
@ -316,4 +317,11 @@ private static Object deserializeObject(byte[] bytes) throws Exception {
private static <T> T unsafeCast(Object o) throws ClassCastException {
return (T)o;
}
@Override
public void close() throws IOException {
if (zkManager != null) {
zkManager.close();
}
}
}