Ejemplo n.º 1
0
 private void doShutdown(boolean force) {
   long start = Clock.currentTimeMillis();
   logger.finest("** we are being asked to shutdown when active = " + String.valueOf(active));
   if (!force && isActive()) {
     final int maxWaitSeconds = groupProperties.GRACEFUL_SHUTDOWN_MAX_WAIT.getInteger();
     if (!partitionService.prepareToSafeShutdown(maxWaitSeconds, TimeUnit.SECONDS)) {
       logger.warning(
           "Graceful shutdown could not be completed in " + maxWaitSeconds + " seconds!");
     }
   }
   if (isActive()) {
     if (!force) {
       clusterService.sendShutdownMessage();
     }
     // set the joined=false first so that
     // threads do not process unnecessary
     // events, such as remove address
     joined.set(false);
     setActive(false);
     setMasterAddress(null);
     try {
       Runtime.getRuntime().removeShutdownHook(shutdownHookThread);
     } catch (Throwable ignored) {
     }
     if (managementCenterService != null) {
       managementCenterService.shutdown();
     }
     logger.finest("Shutting down client command service");
     clientEngine.shutdown();
     logger.finest("Shutting down node engine");
     nodeEngine.shutdown();
     if (multicastService != null) {
       logger.finest("Shutting down multicast service");
       multicastService.stop();
     }
     logger.finest("Shutting down connection manager");
     connectionManager.shutdown();
     textCommandService.stop();
     masterAddress = null;
     if (securityContext != null) {
       securityContext.destroy();
     }
     initializer.destroy();
     serializationService.destroy();
     int numThreads = threadGroup.activeCount();
     Thread[] threads = new Thread[numThreads * 2];
     numThreads = threadGroup.enumerate(threads, false);
     for (int i = 0; i < numThreads; i++) {
       Thread thread = threads[i];
       if (thread.isAlive()) {
         logger.finest("Shutting down thread " + thread.getName());
         thread.interrupt();
       }
     }
     failedConnections.clear();
     systemLogService.shutdown();
     logger.info(
         "Hazelcast Shutdown is completed in " + (Clock.currentTimeMillis() - start) + " ms.");
   }
 }
Ejemplo n.º 2
0
 public void rejoin() {
   systemLogService.logJoin("Rejoining!");
   masterAddress = null;
   joined.set(false);
   clusterService.reset();
   failedConnections.clear();
   join();
 }
Ejemplo n.º 3
0
 Joiner createJoiner() {
   JoinConfig join = config.getNetworkConfig().getJoin();
   if (join.getMulticastConfig().isEnabled() && multicastService != null) {
     logger.info("Creating MulticastJoiner");
     systemLogService.logJoin("Creating MulticastJoiner");
     return new MulticastJoiner(this);
   } else if (join.getTcpIpConfig().isEnabled()) {
     logger.info("Creating TcpIpJoiner");
     systemLogService.logJoin("Creating TcpIpJoiner");
     return new TcpIpJoiner(this);
   } else if (join.getAwsConfig().isEnabled()) {
     Class clazz;
     try {
       logger.info("Creating AWSJoiner");
       clazz = Class.forName("com.hazelcast.cluster.TcpIpJoinerOverAWS");
       Constructor constructor = clazz.getConstructor(Node.class);
       systemLogService.logJoin("Creating AWSJoiner");
       return (Joiner) constructor.newInstance(this);
     } catch (Exception e) {
       logger.severe("Error while creating AWSJoiner!", e);
     }
   }
   return null;
 }
Ejemplo n.º 4
0
 public void setAsMaster() {
   logger.finest("This node is being set as the master");
   systemLogService.logJoin("No master node found! Setting this node as the master.");
   masterAddress = address;
   setJoined();
 }
Ejemplo n.º 5
0
 public void setJoined() {
   joined.set(true);
   systemLogService.logJoin("setJoined() master: " + masterAddress);
 }