예제 #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.");
   }
 }
예제 #2
0
 public ThreadStats(int utilizationPercentage, long runCount, long waitCount, boolean running) {
   this.utilizationPercentage = utilizationPercentage;
   this.runCount = runCount;
   this.waitCount = waitCount;
   this.running = running;
   this.createMillis = Clock.currentTimeMillis();
 }
예제 #3
0
 public void scheduleTtlEviction(String mapName, Record record, long delay) {
   if (record.getStatistics() != null) {
     record.getStatistics().setExpirationTime(Clock.currentTimeMillis() + delay);
   }
   getMapContainer(mapName)
       .getTtlEvictionScheduler()
       .schedule(delay, toData(record.getKey()), null);
 }
예제 #4
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);
     }
   }
 }
 public void logI18nMessageWithUsername(
     final String key, final String username, final String... params) {
   lastModified = new Date(clock.currentTimeMillis());
   AuditLogEntry entry =
       new AuditLogEntryImpl(username, lastModified, key, EntryType.valueOfI18n(key), params);
   try {
     saveEntryAndPurge(entry);
   } catch (IOException e) {
     throw new AuditLoggingException("Failed to log message: " + entry, e);
   }
   log.info(entry.getMessage(i18nResolver));
 }
예제 #6
0
 @Override
 public void testFinished(Description description) {
   getMethodStats(description).stopTime = clock.currentTimeMillis();
 }
예제 #7
0
 private long currentTimeMillis() {
   return _clock.currentTimeMillis();
 }