Search in sources :

Example 1 with TransactionViewWalker

use of org.apache.ignite.internal.managers.systemview.walker.TransactionViewWalker in project ignite by apache.

the class IgniteTxManager method start0.

/**
 * {@inheritDoc}
 */
@Override
protected void start0() throws IgniteCheckedException {
    txHnd = new IgniteTxHandler(cctx);
    deferredAckMsgSnd = new GridDeferredAckMessageSender<GridCacheVersion>(cctx.time(), cctx.kernalContext().closure()) {

        @Override
        public int getTimeout() {
            return DEFERRED_ONE_PHASE_COMMIT_ACK_REQUEST_TIMEOUT;
        }

        @Override
        public int getBufferSize() {
            return DEFERRED_ONE_PHASE_COMMIT_ACK_REQUEST_BUFFER_SIZE;
        }

        @Override
        public void finish(UUID nodeId, Collection<GridCacheVersion> vers) {
            GridDhtTxOnePhaseCommitAckRequest ackReq = new GridDhtTxOnePhaseCommitAckRequest(vers);
            cctx.kernalContext().gateway().readLock();
            try {
                cctx.io().send(nodeId, ackReq, GridIoPolicy.SYSTEM_POOL);
            } catch (ClusterTopologyCheckedException ignored) {
                if (log.isDebugEnabled())
                    log.debug("Failed to send one phase commit ack to backup node because it left grid: " + nodeId);
            } catch (IgniteCheckedException e) {
                log.error("Failed to send one phase commit ack to backup node [backup=" + nodeId + ']', e);
            } finally {
                cctx.kernalContext().gateway().readUnlock();
            }
        }
    };
    cctx.gridEvents().addDiscoveryEventListener(new TransactionRecoveryListener(), EVT_NODE_FAILED, EVT_NODE_LEFT);
    cctx.gridEvents().addDiscoveryEventListener(new DiscoveryEventListener() {

        @Override
        public void onEvent(DiscoveryEvent evt, DiscoCache discoCache) {
            if (evt.type() == EVT_NODE_FAILED || evt.type() == EVT_NODE_LEFT) {
                UUID nodeId = evt.eventNode().id();
                for (TxDeadlockFuture fut : deadlockDetectFuts.values()) fut.onNodeLeft(nodeId);
                for (Map.Entry<GridCacheVersion, Object> entry : completedVersHashMap.entrySet()) {
                    Object obj = entry.getValue();
                    if (obj instanceof GridCacheReturnCompletableWrapper && nodeId.equals(((GridCacheReturnCompletableWrapper) obj).nodeId()))
                        removeTxReturn(entry.getKey());
                }
            }
            suspendResumeForPessimisticSupported = IgniteFeatures.allNodesSupports(cctx.discovery().remoteNodes(), IgniteFeatures.SUSPEND_RESUME_PESSIMISTIC_TX);
        }
    }, EVT_NODE_FAILED, EVT_NODE_LEFT, EVT_NODE_JOINED);
    this.txDeadlockDetection = new TxDeadlockDetection(cctx);
    cctx.gridIO().addMessageListener(TOPIC_TX, new DeadlockDetectionListener());
    cctx.txMetrics().onTxManagerStarted();
    keyCollisionsInfo = new KeyCollisionsHolder();
    distributedTransactionConfiguration = new DistributedTransactionConfiguration(cctx.kernalContext(), log, (String name, Long oldVal, Long newVal) -> {
        if (!Objects.equals(oldVal, newVal)) {
            scheduleDumpTask(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, () -> cctx.kernalContext().closure().runLocalSafe(() -> cctx.kernalContext().cache().context().exchange().dumpLongRunningOperations(newVal)), newVal);
        }
    }, (String name, Integer oldVal, Integer newVal) -> {
        if (!Objects.equals(oldVal, newVal)) {
            scheduleDumpTask(IGNITE_DUMP_TX_COLLISIONS_INTERVAL, this::collectTxCollisionsInfo, newVal);
        }
    });
    cctx.kernalContext().systemView().registerView(TXS_MON_LIST, TXS_MON_LIST_DESC, new TransactionViewWalker(), new ReadOnlyCollectionView2X<>(idMap.values(), nearIdMap.values()), TransactionView::new);
}
Also used : DiscoCache(org.apache.ignite.internal.managers.discovery.DiscoCache) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) DistributedTransactionConfiguration(org.apache.ignite.internal.cluster.DistributedTransactionConfiguration) GridCacheVersion(org.apache.ignite.internal.processors.cache.version.GridCacheVersion) DataEntry(org.apache.ignite.internal.pagemem.wal.record.DataEntry) GridNearCacheEntry(org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheEntry) GridCacheMapEntry(org.apache.ignite.internal.processors.cache.GridCacheMapEntry) GridDistributedCacheEntry(org.apache.ignite.internal.processors.cache.distributed.GridDistributedCacheEntry) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) TransactionViewWalker(org.apache.ignite.internal.managers.systemview.walker.TransactionViewWalker) TransactionView(org.apache.ignite.spi.systemview.view.TransactionView) UUID(java.util.UUID) DiscoveryEventListener(org.apache.ignite.internal.managers.eventstorage.DiscoveryEventListener) GridDhtTxOnePhaseCommitAckRequest(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxOnePhaseCommitAckRequest) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AtomicLong(java.util.concurrent.atomic.AtomicLong) GridCacheReturnCompletableWrapper(org.apache.ignite.internal.processors.cache.GridCacheReturnCompletableWrapper) TxDeadlockFuture(org.apache.ignite.internal.processors.cache.transactions.TxDeadlockDetection.TxDeadlockFuture) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)

Aggregations

UUID (java.util.UUID)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 DiscoveryEvent (org.apache.ignite.events.DiscoveryEvent)1 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)1 DistributedTransactionConfiguration (org.apache.ignite.internal.cluster.DistributedTransactionConfiguration)1 DiscoCache (org.apache.ignite.internal.managers.discovery.DiscoCache)1 DiscoveryEventListener (org.apache.ignite.internal.managers.eventstorage.DiscoveryEventListener)1 TransactionViewWalker (org.apache.ignite.internal.managers.systemview.walker.TransactionViewWalker)1 DataEntry (org.apache.ignite.internal.pagemem.wal.record.DataEntry)1 GridCacheMapEntry (org.apache.ignite.internal.processors.cache.GridCacheMapEntry)1 GridCacheReturnCompletableWrapper (org.apache.ignite.internal.processors.cache.GridCacheReturnCompletableWrapper)1 GridDistributedCacheEntry (org.apache.ignite.internal.processors.cache.distributed.GridDistributedCacheEntry)1 GridDhtTxOnePhaseCommitAckRequest (org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxOnePhaseCommitAckRequest)1 GridNearCacheEntry (org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheEntry)1 TxDeadlockFuture (org.apache.ignite.internal.processors.cache.transactions.TxDeadlockDetection.TxDeadlockFuture)1 GridCacheVersion (org.apache.ignite.internal.processors.cache.version.GridCacheVersion)1 TransactionView (org.apache.ignite.spi.systemview.view.TransactionView)1