code: private void tryHostLock(String hostPath) throws Exception {
  
          //if path has created 60 seconds ago, then delete
          if (registryOperations.exists(hostPath)) {
              try {
                  ServiceRecord host = registryOperations.resolve(hostPath);
                  Long cTime = Long.parseLong(host.get(JOYConstants.CTIME, JOYConstants.DEFAULT_CTIME));
                  Date now = new Date();
                  if (now.getTime() - cTime > JOYConstants.HOST_LOCK_TIMEOUT || cTime > now.getTime())
                      registryOperations.delete(hostPath, true);
              } catch (Exception ex) {
                  LOG.error(ex);
              }
          }
  
          int failedCount = JOYConstants.RETRY_TIMES;
          while (!registryOperations.mknode(hostPath, true)) {
              Thread.sleep(JOYConstants.SLEEP_INTERVAL);
              failedCount--;
              if (failedCount <= 0)
                  break;
          }
  
          if (failedCount > 0) {
              ServiceRecord sr = new ServiceRecord();
              Date date = new Date();
              date.getTime();
              sr.set(JOYConstants.CTIME, String.valueOf(date.getTime()));
              registryOperations.bind(hostPath, sr, BindFlags.OVERWRITE);
              return;
          }
          throw new Exception("can't get host lock");
      }
docs: see if anyone is updating host's port list, if not start , update this host itself
  timeout is 45 seconds
  
  @param hostPath
  @throws InterruptedException
  @throws IOException