Search in sources :

Example 1 with SystemTimerTask

use of org.apache.geode.internal.SystemTimer.SystemTimerTask in project geode by apache.

the class TXManagerImpl method resumeProxy.

private void resumeProxy(TXStateProxy txProxy) {
    assert txProxy != null;
    internalResume(txProxy);
    SystemTimerTask task = this.expiryTasks.remove(txProxy.getTransactionId());
    if (task != null) {
        if (task.cancel()) {
            this.cache.purgeCCPTimer();
        }
    }
}
Also used : SystemTimerTask(org.apache.geode.internal.SystemTimer.SystemTimerTask)

Example 2 with SystemTimerTask

use of org.apache.geode.internal.SystemTimer.SystemTimerTask in project geode by apache.

the class ClientHealthMonitor method expireTXStates.

/**
   * expire the transaction states for the given client. This uses the transactionTimeToLive setting
   * that is inherited from the TXManagerImpl. If that setting is non-positive we expire the states
   * immediately
   * 
   * @param proxyID
   */
private void expireTXStates(ClientProxyMembershipID proxyID) {
    final TXManagerImpl txMgr = (TXManagerImpl) this._cache.getCacheTransactionManager();
    final Set<TXId> txids = txMgr.getTransactionsForClient((InternalDistributedMember) proxyID.getDistributedMember());
    if (this._cache.isClosed()) {
        return;
    }
    long timeout = txMgr.getTransactionTimeToLive() * 1000;
    if (!txids.isEmpty()) {
        if (logger.isDebugEnabled()) {
            logger.debug("expiring {} transaction contexts for {} timeout={}", txids.size(), proxyID, timeout / 1000);
        }
        if (timeout <= 0) {
            txMgr.removeTransactions(txids, true);
        } else {
            if (scheduledToBeRemovedTx != null)
                scheduledToBeRemovedTx.addAll(txids);
            SystemTimerTask task = new SystemTimerTask() {

                @Override
                public void run2() {
                    txMgr.removeTransactions(txids, true);
                    if (scheduledToBeRemovedTx != null)
                        scheduledToBeRemovedTx.removeAll(txids);
                }
            };
            this._cache.getCCPTimer().schedule(task, timeout);
        }
    }
}
Also used : TXManagerImpl(org.apache.geode.internal.cache.TXManagerImpl) TXId(org.apache.geode.internal.cache.TXId) SystemTimerTask(org.apache.geode.internal.SystemTimer.SystemTimerTask)

Example 3 with SystemTimerTask

use of org.apache.geode.internal.SystemTimer.SystemTimerTask in project geode by apache.

the class TXManagerImpl method scheduleExpiry.

/**
   * schedules the transaction to expire after {@link #suspendedTXTimeout}
   * 
   * @param expiryTimeUnit the time unit to use when scheduling the expiration
   */
private void scheduleExpiry(TransactionId txId, TimeUnit expiryTimeUnit) {
    if (suspendedTXTimeout < 0) {
        if (logger.isDebugEnabled()) {
            logger.debug("TX: transaction: {} not scheduled to expire", txId);
        }
        return;
    }
    SystemTimerTask task = new TXExpiryTask(txId);
    if (logger.isDebugEnabled()) {
        logger.debug("TX: scheduling transaction: {} to expire after:{}", txId, suspendedTXTimeout);
    }
    cache.getCCPTimer().schedule(task, TimeUnit.MILLISECONDS.convert(suspendedTXTimeout, expiryTimeUnit));
    this.expiryTasks.put(txId, task);
}
Also used : SystemTimerTask(org.apache.geode.internal.SystemTimer.SystemTimerTask)

Example 4 with SystemTimerTask

use of org.apache.geode.internal.SystemTimer.SystemTimerTask in project geode by apache.

the class CacheClientProxy method scheduleDurableExpirationTask.

protected void scheduleDurableExpirationTask() {
    SystemTimer.SystemTimerTask task = new SystemTimer.SystemTimerTask() {

        @Override
        public void run2() {
            _durableExpirationTask.compareAndSet(this, null);
            logger.warn(LocalizedMessage.create(LocalizedStrings.CacheClientProxy_0__THE_EXPIRATION_TASK_HAS_FIRED_SO_THIS_PROXY_IS_BEING_TERMINATED, CacheClientProxy.this));
            // Remove the proxy from the CacheClientNofier's registry
            getCacheClientNotifier().removeClientProxy(CacheClientProxy.this);
            getCacheClientNotifier().durableClientTimedOut(CacheClientProxy.this.proxyID);
            // Close the proxy
            terminateDispatching(false);
            _cacheClientNotifier.statistics.incQueueDroppedCount();
            /**
         * Setting the expiration task to null again and cancelling existing one, if any. See
         * #50894.
         * <p/>
         * The message dispatcher may again set the expiry task in below path: <code>
         *  org.apache.geode.internal.cache.tier.sockets.CacheClientProxy.scheduleDurableExpirationTask(CacheClientProxy.java:2020)
         *  org.apache.geode.internal.cache.tier.sockets.CacheClientProxy.pauseDispatching(CacheClientProxy.java:924)
         *  org.apache.geode.internal.cache.tier.sockets.CacheClientProxy$MessageDispatcher.pauseOrUnregisterProxy(CacheClientProxy.java:2813)
         *  org.apache.geode.internal.cache.tier.sockets.CacheClientProxy$MessageDispatcher.run(CacheClientProxy.java:2692)
         * </code>
         * <p/>
         * This is because message dispatcher may get an IOException with "Proxy closing due to
         * socket being closed locally" during/after terminateDispatching(false) above.
         */
            Object task = _durableExpirationTask.getAndSet(null);
            if (task != null) {
                if (((SystemTimerTask) task).cancel()) {
                    _cache.purgeCCPTimer();
                }
            }
        }
    };
    if (this._durableExpirationTask.compareAndSet(null, task)) {
        _cache.getCCPTimer().schedule(task, getDurableTimeout() * 1000L);
    }
}
Also used : SystemTimerTask(org.apache.geode.internal.SystemTimer.SystemTimerTask) SystemTimerTask(org.apache.geode.internal.SystemTimer.SystemTimerTask) SystemTimer(org.apache.geode.internal.SystemTimer)

Aggregations

SystemTimerTask (org.apache.geode.internal.SystemTimer.SystemTimerTask)4 SystemTimer (org.apache.geode.internal.SystemTimer)1 TXId (org.apache.geode.internal.cache.TXId)1 TXManagerImpl (org.apache.geode.internal.cache.TXManagerImpl)1