int tries = 0;
while (tries < maxTries) {
AvatarZooKeeperClient zk = new AvatarZooKeeperClient(conf, null);
try {
ssid = now();
zk.registerPrimarySsId(getClusterAddress(conf), ssid);
// Be extra careful and verify the data was synced to zk.
Long ssIdInZk = zk.getPrimarySsId(getClusterAddress(conf));
if (ssid != ssIdInZk) {
throw new IOException("Session Id in the NameNode : " + ssid +
" does not match the session Id in Zookeeper : " + ssIdInZk);