コード例 #1
0
 CacheEventHandler(NodeEngine nodeEngine) {
   this.nodeEngine = nodeEngine;
   GroupProperties groupProperties = nodeEngine.getGroupProperties();
   invalidationMessageBatchEnabled =
       groupProperties.getBoolean(CACHE_INVALIDATION_MESSAGE_BATCH_ENABLED);
   if (invalidationMessageBatchEnabled) {
     invalidationMessageBatchSize =
         groupProperties.getInteger(CACHE_INVALIDATION_MESSAGE_BATCH_SIZE);
     int invalidationMessageBatchFreq =
         groupProperties.getInteger(CACHE_INVALIDATION_MESSAGE_BATCH_FREQUENCY_SECONDS);
     ExecutionService executionService = nodeEngine.getExecutionService();
     CacheBatchInvalidationMessageSender batchInvalidationMessageSender =
         new CacheBatchInvalidationMessageSender();
     cacheBatchInvalidationMessageSenderScheduler =
         executionService.scheduleWithRepetition(
             ICacheService.SERVICE_NAME + ":cacheBatchInvalidationMessageSender",
             batchInvalidationMessageSender,
             invalidationMessageBatchFreq,
             invalidationMessageBatchFreq,
             TimeUnit.SECONDS);
   }
   LifecycleService lifecycleService = nodeEngine.getHazelcastInstance().getLifecycleService();
   lifecycleService.addLifecycleListener(
       new LifecycleListener() {
         @Override
         public void stateChanged(LifecycleEvent event) {
           if (event.getState() == LifecycleEvent.LifecycleState.SHUTTING_DOWN) {
             invalidateAllCaches();
           }
         }
       });
 }
コード例 #2
0
  public void close(Throwable t) {
    if (!live.compareAndSet(true, false)) {
      return;
    }
    String message =
        "Connection ["
            + socketChannelWrapper.socket().getRemoteSocketAddress()
            + "] lost. Reason: ";
    if (t != null) {
      message += t.getClass().getName() + "[" + t.getMessage() + "]";
    } else {
      message += "Socket explicitly closed";
    }

    try {
      innerClose();
    } catch (Exception e) {
      logger.warning(e);
    }

    if (lifecycleService.isRunning()) {
      logger.warning(message);
    } else {
      logger.finest(message);
    }
  }
コード例 #3
0
  public void notifyException(Throwable exception) {
    if (!lifecycleService.isRunning()) {
      clientInvocationFuture.complete(
          new HazelcastClientNotActiveException(exception.getMessage(), exception));
      return;
    }

    if (isRetryable(exception)) {
      if (handleRetry()) {
        return;
      }
    }
    if (exception instanceof RetryableHazelcastException) {
      if (clientMessage.isRetryable() || invocationService.isRedoOperation()) {
        if (handleRetry()) {
          return;
        }
      }
    }
    clientInvocationFuture.complete(exception);
  }
コード例 #4
0
  public void notifyException(Throwable exception) {

    if (!lifecycleService.isRunning()) {
      clientInvocationFuture.setResponse(
          new HazelcastClientNotActiveException(exception.getMessage()));
      return;
    }

    if (exception instanceof IOException
        || exception instanceof HazelcastInstanceNotActiveException
        || exception instanceof AuthenticationException) {
      if (handleRetry()) {
        return;
      }
    }
    if (exception instanceof RetryableHazelcastException) {
      if (clientMessage.isRetryable() || invocationService.isRedoOperation()) {
        if (handleRetry()) {
          return;
        }
      }
    }
    clientInvocationFuture.setResponse(exception);
  }