コード例 #1
0
 @Override
 public void waitForReady() {
   while (true) {
     try {
       rootNode.exists();
       break;
     } catch (Throwable e) {
       // do nothing
     }
     try {
       Thread.sleep(INITIALIZATION_SLEEP_PERIOD);
       log.info("Znode structure is not initialized. Waiting {} ms", INITIALIZATION_SLEEP_PERIOD);
     } catch (InterruptedException e) {
       log.warn("Sleep interrupted", e);
     }
   }
 }
コード例 #2
0
  @Override
  public void waitForInitialization() {
    log.info("Waiting for coordination znode structure structure initialization");
    while (true) {
      boolean initialized =
          rootNode.exists() && rootNode.hasChild(CoordinationUtil.STATUSES_NODE_NAME);

      if (initialized) {
        log.info("Coordination znode structure initialized");
        break;
      }

      try {
        Thread.sleep(INITIALIZATION_SLEEP_PERIOD);
        log.info("Znode structure is not initialized. Waiting {} ms", INITIALIZATION_SLEEP_PERIOD);
      } catch (InterruptedException e) {
        log.warn("Sleep interrupted", e);
      }
    }
  }