YARN-10194. YARN RMWebServices /scheduler-conf/validate leaks ZK Connections. Contributed by Prabhu Joseph
This commit is contained in:
parent
85516a8af7
commit
f91e21ac10
|
@ -42,14 +42,18 @@ public final class CapacitySchedulerConfigValidator {
|
|||
public static boolean validateCSConfiguration(
|
||||
final Configuration oldConf, final Configuration newConf,
|
||||
final RMContext rmContext) throws IOException {
|
||||
//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;
|
||||
try {
|
||||
//TODO: extract all the validation steps and replace reinitialize with
|
||||
//the specific validation steps
|
||||
newCs.setConf(oldConf);
|
||||
newCs.setRMContext(rmContext);
|
||||
newCs.init(oldConf);
|
||||
newCs.reinitialize(newConf, rmContext, true);
|
||||
return true;
|
||||
} finally {
|
||||
newCs.stop();
|
||||
}
|
||||
}
|
||||
|
||||
public static Set<String> validatePlacementRules(
|
||||
|
|
|
@ -358,6 +358,7 @@ public class FSSchedulerConfigurationStore extends YarnConfigurationStore {
|
|||
return CURRENT_VERSION_INFO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (fileSystem != null) {
|
||||
fileSystem.close();
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.apache.hadoop.conf.Configuration;
|
|||
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 class InMemoryConfigurationStore extends YarnConfigurationStore {
|
|||
public void checkVersion() {
|
||||
// Does nothing. (Version is always compatible since it's in memory)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
// Does nothing.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ public abstract class YarnConfigurationStore {
|
|||
* 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.
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
|
|||
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 @@ public class ZKConfigurationStore extends YarnConfigurationStore {
|
|||
private static <T> T unsafeCast(Object o) throws ClassCastException {
|
||||
return (T)o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (zkManager != null) {
|
||||
zkManager.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue