コード例 #1
0
 @Start(priority = 9) // Start before cache loader manager
 @SuppressWarnings("unused")
 private void start() {
   final int concurrencyLevel = configuration.locking().concurrencyLevel();
   localTransactions =
       ConcurrentMapFactory.makeConcurrentMap(concurrencyLevel, 0.75f, concurrencyLevel);
   globalToLocalTransactions =
       ConcurrentMapFactory.makeConcurrentMap(concurrencyLevel, 0.75f, concurrencyLevel);
   if (configuration.clustering().cacheMode().isClustered()) {
     minTopologyRecalculationLock = new ReentrantLock();
     // Only initialize this if we are clustered.
     remoteTransactions =
         ConcurrentMapFactory.makeConcurrentMap(concurrencyLevel, 0.75f, concurrencyLevel);
     cleanupService.start(cacheName, rpcManager, configuration);
     notifier.addListener(cleanupService);
     notifier.addListener(this);
     clustered = true;
   }
 }
コード例 #2
0
  @Start(priority = 9) // Start before cache loader manager
  @SuppressWarnings("unused")
  private void start() {
    final int concurrencyLevel = configuration.locking().concurrencyLevel();
    localTransactions =
        CollectionFactory.makeConcurrentMap(concurrencyLevel, 0.75f, concurrencyLevel);
    globalToLocalTransactions =
        CollectionFactory.makeConcurrentMap(concurrencyLevel, 0.75f, concurrencyLevel);
    if (configuration.clustering().cacheMode().isClustered()) {
      minTopologyRecalculationLock = new ReentrantLock();
      // Only initialize this if we are clustered.
      remoteTransactions =
          CollectionFactory.makeConcurrentMap(concurrencyLevel, 0.75f, concurrencyLevel);
      notifier.addListener(this);
      clustered = true;
    }

    totalOrder = configuration.transaction().transactionProtocol().isTotalOrder();
    if (!totalOrder) {
      // Periodically run a task to cleanup the transaction table from completed transactions.
      ThreadFactory tf =
          new ThreadFactory() {
            @Override
            public Thread newThread(Runnable r) {
              String address =
                  rpcManager != null ? rpcManager.getTransport().getAddress().toString() : "local";
              Thread th = new Thread(r, "TxCleanupService," + cacheName + "," + address);
              th.setDaemon(true);
              return th;
            }
          };

      executorService = Executors.newSingleThreadScheduledExecutor(tf);

      long interval = configuration.transaction().reaperWakeUpInterval();
      executorService.scheduleAtFixedRate(
          new Runnable() {
            @Override
            public void run() {
              cleanupCompletedTransactions();
            }
          },
          interval,
          interval,
          TimeUnit.MILLISECONDS);
    }
  }
コード例 #3
0
 @Start
 private void start() {
   final int concurrencyLevel = configuration.locking().concurrencyLevel();
   localTransactions =
       ConcurrentMapFactory.makeConcurrentMap(concurrencyLevel, 0.75f, concurrencyLevel);
   if (configuration.clustering().cacheMode().isClustered()) {
     minViewRecalculationLock = new ReentrantLock();
     // Only initialize this if we are clustered.
     remoteTransactions =
         ConcurrentMapFactory.makeConcurrentMap(concurrencyLevel, 0.75f, concurrencyLevel);
     cleanupService.start(cacheName, rpcManager, invoker);
     cm.addListener(cleanupService);
     cm.addListener(this);
     notifier.addListener(cleanupService);
     minTxViewId = rpcManager.getTransport().getViewId();
     currentViewId = minTxViewId;
     log.debugf("Min view id set to %s", minTxViewId);
     clustered = true;
   }
 }
コード例 #4
0
ファイル: CacheImpl.java プロジェクト: oranheim/infinispan
 public void addListener(Object listener) {
   notifier.addListener(listener);
 }
コード例 #5
0
  @Start(priority = 9) // Start before cache loader manager
  @SuppressWarnings("unused")
  public void start() {
    final int concurrencyLevel = configuration.locking().concurrencyLevel();
    // use the IdentityEquivalence because some Transaction implementation does not have a stable
    // hash code function
    // and it can cause some leaks in the concurrent map.
    localTransactions =
        CollectionFactory.makeConcurrentMap(
            concurrencyLevel,
            0.75f,
            concurrencyLevel,
            new IdentityEquivalence<Transaction>(),
            AnyEquivalence.getInstance());
    globalToLocalTransactions =
        CollectionFactory.makeConcurrentMap(concurrencyLevel, 0.75f, concurrencyLevel);

    boolean transactional = configuration.transaction().transactionMode().isTransactional();
    if (clustered && transactional) {
      minTopologyRecalculationLock = new ReentrantLock();
      remoteTransactions =
          CollectionFactory.makeConcurrentMap(concurrencyLevel, 0.75f, concurrencyLevel);

      ThreadFactory tf =
          new ThreadFactory() {
            @Override
            public Thread newThread(Runnable r) {
              String address =
                  rpcManager != null ? rpcManager.getTransport().getAddress().toString() : "local";
              Thread th = new Thread(r, "TxCleanupService," + cacheName + "," + address);
              th.setDaemon(true);
              return th;
            }
          };
      executorService = Executors.newSingleThreadScheduledExecutor(tf);

      notifier.addListener(this);
      cacheManagerNotifier.addListener(this);

      boolean totalOrder = configuration.transaction().transactionProtocol().isTotalOrder();
      if (!totalOrder) {
        completedTransactionsInfo = new CompletedTransactionsInfo();

        // Periodically run a task to cleanup the transaction table of completed transactions.
        long interval = configuration.transaction().reaperWakeUpInterval();
        executorService.scheduleAtFixedRate(
            new Runnable() {
              @Override
              public void run() {
                completedTransactionsInfo.cleanupCompletedTransactions();
              }
            },
            interval,
            interval,
            TimeUnit.MILLISECONDS);

        executorService.scheduleAtFixedRate(
            new Runnable() {
              @Override
              public void run() {
                cleanupTimedOutTransactions();
              }
            },
            interval,
            interval,
            TimeUnit.MILLISECONDS);
      }
    }
  }