code: public synchronized void waitForAllNodesRegistered(int timeoutMs)
        throws TimeoutException, InterruptedException {
      MetaMasterClient metaMasterClient = getMetaMasterClient();
      CommonUtils.waitFor("all nodes registered", () -> {
        try {
          MasterInfo masterInfo = metaMasterClient.getMasterInfo(Collections.emptySet());
          int liveNodeNum = masterInfo.getMasterAddressesList().size()
              + masterInfo.getWorkerAddressesList().size();
          if (liveNodeNum == (mNumMasters + mNumWorkers)) {
            return true;
          } else {
            LOG.info("Master addresses: {}. Worker addresses: {}",
                masterInfo.getMasterAddressesList(), masterInfo.getWorkerAddressesList());
            return false;
          }
        } catch (UnavailableException e) {
          return false;
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
      }, WaitForOptions.defaults().setInterval(200).setTimeoutMs(timeoutMs));
    }
docs: Waits for all nodes to be registered.
  
  @param timeoutMs maximum amount of time to wait, in milliseconds