Пример #1
0
  private boolean prepareClusterState(ClusterServiceImpl clusterService) {
    if (!preCheckClusterState(clusterService)) {
      return false;
    }

    long until = Clock.currentTimeMillis() + mergeNextRunDelayMs;
    while (clusterService.getClusterState() == ClusterState.ACTIVE) {
      try {
        clusterService.changeClusterState(ClusterState.FROZEN);
        return true;
      } catch (Exception e) {
        String error = e.getClass().getName() + ": " + e.getMessage();
        logger.warning("While freezing cluster state! " + error);
      }

      if (Clock.currentTimeMillis() >= until) {
        logger.warning(
            "Could not change cluster state to FROZEN in time. "
                + "Postponing merge process until next attempt.");
        return false;
      }

      try {
        TimeUnit.SECONDS.sleep(1);
      } catch (InterruptedException e) {
        logger.warning("Interrupted while preparing cluster for merge!");
        // restore interrupt flag
        Thread.currentThread().interrupt();
        return false;
      }
    }
    return false;
  }
Пример #2
0
 @Override
 public void shutdown(TransactionOptions options) {
   changeClusterState(ClusterState.PASSIVE, options);
   shutdownNodes();
 }
Пример #3
0
 @Override
 public void shutdown() {
   changeClusterState(ClusterState.PASSIVE);
   shutdownNodes();
 }