示例#1
0
  private void shutdownNodes() {
    final Operation op = new ShutdownNodeOperation();

    logger.info("Sending shutting down operations to all members...");

    Collection<Member> members = getMembers(NON_LOCAL_MEMBER_SELECTOR);
    final long timeout =
        node.groupProperties.getNanos(GroupProperty.CLUSTER_SHUTDOWN_TIMEOUT_SECONDS);
    final long startTime = System.nanoTime();

    while ((System.nanoTime() - startTime) < timeout && !members.isEmpty()) {
      for (Member member : members) {
        nodeEngine.getOperationService().send(op, member.getAddress());
      }

      try {
        Thread.sleep(CLUSTER_SHUTDOWN_SLEEP_DURATION_IN_MILLIS);
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        logger.warning("Shutdown sleep interrupted. ", e);
        break;
      }

      members = getMembers(NON_LOCAL_MEMBER_SELECTOR);
    }

    logger.info(
        "Number of other nodes remaining: "
            + getSize(NON_LOCAL_MEMBER_SELECTOR)
            + ". Shutting down itself.");
    node.shutdown(false);
  }
示例#2
0
 public void join() {
   final long joinStartTime = joiner != null ? joiner.getStartTime() : Clock.currentTimeMillis();
   final long maxJoinMillis = getGroupProperties().MAX_JOIN_SECONDS.getInteger() * 1000;
   try {
     if (joiner == null) {
       logger.warning("No join method is enabled! Starting standalone.");
       setAsMaster();
     } else {
       joiner.join(joined);
     }
   } catch (Exception e) {
     if (Clock.currentTimeMillis() - joinStartTime < maxJoinMillis) {
       logger.warning("Trying to rejoin: " + e.getMessage());
       rejoin();
     } else {
       logger.severe("Could not join cluster, shutting down!", e);
       shutdown(false, true);
     }
   }
 }
示例#3
0
 public static void terminateInstance(HazelcastInstance hz) {
   final Node node = getNode(hz);
   node.getConnectionManager().shutdown();
   node.shutdown(true);
 }