docs: private boolean prepareClusterState(ClusterServiceImpl clusterService, int expectedMemberListVersion) {
          if (!preCheckClusterState(clusterService)) {
              return false;
          }
  
          long until = Clock.currentTimeMillis() + mergeNextRunDelayMs;
          while (Clock.currentTimeMillis() < until) {
              ClusterState clusterState = clusterService.getClusterState();
              if (!clusterState.isMigrationAllowed() && !clusterState.isJoinAllowed() && clusterState != IN_TRANSITION) {
                  return (clusterService.getMemberListVersion() == expectedMemberListVersion);
              }
  
              if (clusterService.getMemberListVersion() != expectedMemberListVersion) {
                  logger.warning("Could not change cluster state to FROZEN because local member list version: "
                          + clusterService.getMemberListVersion() + " is different than expected member list version: "
                          + expectedMemberListVersion);
                  return false;
              }
  
              // If state is IN_TRANSITION, then skip trying to change state.
              // Otherwise transaction will print noisy warning logs.
              if (clusterState != IN_TRANSITION) {
                  try {
                      clusterService.changeClusterState(FROZEN);
  
                      return verifyMemberListVersionAfterStateChange(clusterService, clusterState, expectedMemberListVersion);
                  } catch (Exception e) {
                      String error = e.getClass().getName() + ": " + e.getMessage();
                      logger.warning("While changing cluster state to FROZEN! " + error);
                  }
              }
  
              try {
                  TimeUnit.SECONDS.sleep(1);
              } catch (InterruptedException e) {
                  logger.warning("Interrupted while preparing cluster for merge!");
                  // restore interrupt flag
                  Thread.currentThread().interrupt();
                  return false;
              }
          }
  
          logger.warning("Could not change cluster state to FROZEN in time. Postponing merge process until next attempt.");
          return false;
      }