/** * @param keys Keys. * @param txLocks Tx locks. */ private void map(@Nullable Set<IgniteTxKey> keys, Map<IgniteTxKey, TxLockList> txLocks) { mapTxKeys(keys, txLocks); UUID nodeId = nodesQueue.pollFirst(); boolean set = compareAndSet(null, nodeId); assert set; if (nodeId == null || itersCnt++ >= DEADLOCK_MAX_ITERS || timedOut) onDone(); else { final Set<IgniteTxKey> txKeys = pendingKeys.get(nodeId); processedKeys.addAll(txKeys); processedNodes.add(nodeId); pendingKeys.remove(nodeId); cctx.tm().txLocksInfo(nodeId, this, txKeys); } }
/** {@inheritDoc} */ @Override public void onDisconnected(IgniteFuture reconnectFut) { txFinishSync.onDisconnected(reconnectFut); for (IgniteInternalTx tx : idMap.values()) { rollbackTx(tx, true, false); tx.state(ROLLING_BACK); tx.state(ROLLED_BACK); } for (IgniteInternalTx tx : nearIdMap.values()) { rollbackTx(tx, true, false); tx.state(ROLLING_BACK); tx.state(ROLLED_BACK); } IgniteClientDisconnectedException err = new IgniteClientDisconnectedException(reconnectFut, "Client node disconnected."); for (TxDeadlockFuture fut : deadlockDetectFuts.values()) fut.onDone(err); }
/** */ private void init() { cctx.tm().addFuture(this); if (topVer == null) // Tx manager already stopped onDone(); else map(keys, Collections.<IgniteTxKey, TxLockList>emptyMap()); }
fut.onResult(nodeId, res); else fut.onDone(null, err);
/** * @param nodeId Node ID. * @param fut Future. * @param txKeys Tx keys. */ void txLocksInfo(UUID nodeId, TxDeadlockFuture fut, Set<IgniteTxKey> txKeys) { ClusterNode node = cctx.node(nodeId); if (node == null) { if (log.isDebugEnabled()) log.debug("Failed to finish deadlock detection, node left: " + nodeId); fut.onDone(); return; } TxLocksRequest req = new TxLocksRequest(fut.futureId(), txKeys); try { if (!cctx.localNodeId().equals(nodeId)) req.prepareMarshal(cctx); cctx.gridIO().sendToGridTopic(node, TOPIC_TX, req, SYSTEM_POOL); } catch (IgniteCheckedException e) { if (e instanceof ClusterTopologyCheckedException) { if (log.isDebugEnabled()) log.debug("Failed to finish deadlock detection, node left: " + nodeId); } else U.warn(log, "Failed to finish deadlock detection: " + e, e); fut.onDone(); } }
/** {@inheritDoc} */ @Override public void onDisconnected(IgniteFuture reconnectFut) { txFinishSync.onDisconnected(reconnectFut); for (IgniteInternalTx tx : idMap.values()) { rollbackTx(tx, true, false); tx.state(ROLLING_BACK); tx.state(ROLLED_BACK); } for (IgniteInternalTx tx : nearIdMap.values()) { rollbackTx(tx, true, false); tx.state(ROLLING_BACK); tx.state(ROLLED_BACK); } IgniteClientDisconnectedException err = new IgniteClientDisconnectedException(reconnectFut, "Client node disconnected."); for (TxDeadlockFuture fut : deadlockDetectFuts.values()) fut.onDone(err); }
/** * @param res Response. */ public void onResult(UUID nodeId, TxLocksResponse res) { boolean set = compareAndSet(nodeId, null); if (res != null && set) { if (res.classError() != null) { IgniteLogger log = cctx.kernalContext().log(this.getClass()); U.warn(log, "Failed to finish deadlock detection due to an error: " + nodeId); onDone(); } else detect(res); } else onDone(); }
/** * @param keys Keys. * @param txLocks Tx locks. */ private void map(@Nullable Set<IgniteTxKey> keys, Map<IgniteTxKey, TxLockList> txLocks) { mapTxKeys(keys, txLocks); UUID nodeId = nodesQueue.pollFirst(); boolean set = compareAndSet(null, nodeId); assert set; if (nodeId == null || itersCnt++ >= DEADLOCK_MAX_ITERS || timedOut) onDone(); else { final Set<IgniteTxKey> txKeys = pendingKeys.get(nodeId); processedKeys.addAll(txKeys); processedNodes.add(nodeId); pendingKeys.remove(nodeId); cctx.tm().txLocksInfo(nodeId, this, txKeys); } }
/** * @param res Response. */ private void detect(TxLocksResponse res) { assert res != null; merge(res); updateWaitForGraph(res.txLocks()); List<GridCacheVersion> cycle = findCycle(wfg, txId); if (cycle != null) onDone(new TxDeadlock(cycle, txs, txLockedKeys, txRequestedKeys)); else map(res.keys(), res.txLocks()); }
/** * @param nodeId Node ID. */ public void onNodeLeft(UUID nodeId) { if (compareAndSet(nodeId, null)) { IgniteLogger log = cctx.logger(TxDeadlockDetection.class); if (log.isDebugEnabled()) log.debug("Failed to finish deadlock detection, node left: " + nodeId); onDone(); } }
/** {@inheritDoc} */ @Override public void onTimeout() { timedOut = true; IgniteLogger log = cctx.kernalContext().log(this.getClass()); U.warn(log, "Deadlock detection was timed out [timeout=" + DEADLOCK_TIMEOUT + ", fut=" + this + ']'); onDone(); }
/** */ private void init() { cctx.tm().addFuture(this); if (topVer == null) // Tx manager already stopped onDone(); else map(keys, Collections.<IgniteTxKey, TxLockList>emptyMap()); }
fut.onResult(nodeId, res); else fut.onDone(null, err);
/** * @param nodeId Node ID. * @param fut Future. * @param txKeys Tx keys. */ void txLocksInfo(UUID nodeId, TxDeadlockFuture fut, Set<IgniteTxKey> txKeys) { ClusterNode node = cctx.node(nodeId); if (node == null) { if (log.isDebugEnabled()) log.debug("Failed to finish deadlock detection, node left: " + nodeId); fut.onDone(); return; } TxLocksRequest req = new TxLocksRequest(fut.futureId(), txKeys); try { if (!cctx.localNodeId().equals(nodeId)) req.prepareMarshal(cctx); cctx.gridIO().sendToGridTopic(node, TOPIC_TX, req, SYSTEM_POOL); } catch (IgniteCheckedException e) { if (e instanceof ClusterTopologyCheckedException) { if (log.isDebugEnabled()) log.debug("Failed to finish deadlock detection, node left: " + nodeId); } else U.warn(log, "Failed to finish deadlock detection: " + e, e); fut.onDone(); } }
/** * @param res Response. */ public void onResult(UUID nodeId, TxLocksResponse res) { boolean set = compareAndSet(nodeId, null); if (res != null && set) { if (res.classError() != null) { IgniteLogger log = cctx.kernalContext().log(this.getClass()); U.warn(log, "Failed to finish deadlock detection due to an error: " + nodeId); onDone(); } else detect(res); } else onDone(); }
/** * @param nodeId Node ID. */ public void onNodeLeft(UUID nodeId) { if (compareAndSet(nodeId, null)) { IgniteLogger log = cctx.logger(TxDeadlockDetection.class); if (log.isDebugEnabled()) log.debug("Failed to finish deadlock detection, node left: " + nodeId); onDone(); } }
/** * @param res Response. */ private void detect(TxLocksResponse res) { assert res != null; merge(res); updateWaitForGraph(res.txLocks()); List<GridCacheVersion> cycle = findCycle(wfg, txId); if (cycle != null) onDone(new TxDeadlock(cycle, txs, txLockedKeys, txRequestedKeys)); else map(res.keys(), res.txLocks()); }
/** {@inheritDoc} */ @Override public void onTimeout() { timedOut = true; IgniteLogger log = cctx.kernalContext().log(this.getClass()); U.warn(log, "Deadlock detection was timed out [timeout=" + DEADLOCK_TIMEOUT + ", fut=" + this + ']'); onDone(); }