HADOOP-8405. ZKFC tests leak ZK instances. Contributed by Todd Lipcon.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-3042@1339435 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Todd Lipcon 2012-05-17 00:38:59 +00:00
parent 0600e834be
commit 7b1d347b43
3 changed files with 16 additions and 1 deletions

View File

@ -25,3 +25,5 @@ HADOOP-8306. ZKFC: improve error message when ZK is not running. (todd)
HADOOP-8279. Allow manual failover to be invoked when auto-failover is enabled. (todd)
HADOOP-8276. Auto-HA: add config for java options to pass to zkfc daemon (todd via eli)
HADOOP-8405. ZKFC tests leak ZK instances. (todd)

View File

@ -717,11 +717,20 @@ private boolean reEstablishSession() {
}
private void createConnection() throws IOException {
if (zkClient != null) {
try {
zkClient.close();
} catch (InterruptedException e) {
throw new IOException("Interrupted while closing ZK",
e);
}
zkClient = null;
}
zkClient = getNewZooKeeper();
LOG.debug("Created new connection for " + this);
}
private void terminateConnection() {
void terminateConnection() {
if (zkClient == null) {
return;
}

View File

@ -163,6 +163,10 @@ public Integer run() {
return doRun(args);
} catch (Exception t) {
throw new RuntimeException(t);
} finally {
if (elector != null) {
elector.terminateConnection();
}
}
}
});