修改zookeeper会话过期重连

git-svn-id: http://code.alibabatech.com/svn/dubbo/trunk@220 1a56cb94-b969-4eaa-88fa-be21384802f2
This commit is contained in:
william.liangf 2011-11-09 10:39:39 +00:00
parent d282736811
commit cb73a3a271
1 changed files with 16 additions and 16 deletions

View File

@ -74,26 +74,26 @@ public class ZookeeperRegistry extends FailbackRegistry {
@Override
protected void doRetry() {
ZooKeeper zk = this.zookeeper;
if (zk == null || zk.getState() == null || ! zk.getState().isAlive()) {
initZookeeper();
}
initZookeeper();
}
private void initZookeeper() {
zookeeperLock.lock();
try {
ZooKeeper zk = this.zookeeper;
if (zk == null || zk.getState() == null || ! zk.getState().isAlive()) {
this.zookeeper = createZookeeper();
ZooKeeper zk = this.zookeeper;
if (zk == null || zk.getState() == null || ! zk.getState().isAlive()) {
zookeeperLock.lock();
try {
zk = this.zookeeper;
if (zk == null || zk.getState() == null || ! zk.getState().isAlive()) {
this.zookeeper = createZookeeper();
}
if (zk != null) {
zk.close();
}
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
} finally {
zookeeperLock.unlock();
}
if (zk != null) {
zk.close();
}
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
} finally {
zookeeperLock.unlock();
}
}