Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Did not wait for the zk session caused every operation become very slow #64

Open
maxpaynebupt opened this issue Nov 8, 2018 · 0 comments

Comments

@maxpaynebupt
Copy link

I can not commit or push code, so, just point out what the problem is and how to fix it.

The gui is very slow while we do any action on it, that's because every time it start up a new connection to zk server.

The problem exists in the com.deem.zkui.utils.ServletUtil.java's getZookeeper function.

It did not wait for the zk to establish connection to zk server.
'''
zk = ZooKeeperUtil.INSTANCE.createZKConnection(zkServer, zkSessionTimeout);
ZooKeeperUtil.INSTANCE.setDefaultAcl(globalProps.getProperty("defaultAcl"));
if (zk.getState() != ZooKeeper.States.CONNECTED) {
session.setAttribute("zk", null);
} else {
session.setAttribute("zk", zk);
}
'''

fix, add a sleep before check the connection status:
'''
zk = ZooKeeperUtil.INSTANCE.createZKConnection(zkServer, zkSessionTimeout);
ZooKeeperUtil.INSTANCE.setDefaultAcl(globalProps.getProperty("defaultAcl"));
while (zk.getState() == ZooKeeper.States.CONNECTING){
Thread.sleep(100);
}
if (zk.getState() != ZooKeeper.States.CONNECTED) {
session.setAttribute("zk", null);
} else {
session.setAttribute("zk", zk);
}
'''

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant