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);
}
'''
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); } '''