/** * @param commit Commit flag. * @return {@code True} if need to send finish request for one phase commit transaction. */ private boolean needFinishOnePhase(boolean commit) { assert tx.onePhaseCommit(); if (tx.mappings().empty()) return false; if (!commit) return true; GridDistributedTxMapping mapping = tx.mappings().singleMapping(); assert mapping != null; return mapping.hasNearCacheEntries(); }
/** {@inheritDoc} */ @Override public boolean onDone(@Nullable IgniteInternalTx res, @Nullable Throwable err) { if (err != null) ERR_UPD.compareAndSet(GridNearPessimisticTxPrepareFuture.this, null, err); err = this.err; if ((!tx.onePhaseCommit() || tx.mappings().get(cctx.localNodeId()) == null) && (err == null || tx.needCheckBackup())) tx.state(PREPARED); if (super.onDone(tx, err)) { cctx.mvcc().removeVersionedFuture(this); return true; } return false; }
/** * @param node Node. */ private void map(ClusterNode node) { GridDistributedTxMapping mapping = tx.mappings().get(node.id()); if (mapping == null) tx.mappings().put(mapping = new GridDistributedTxMapping(node)); mapping.markQueryUpdate(); if (node.isLocal()) tx.colocatedLocallyMapped(true); int futId = futuresCountNoLock(); miniFutIds.put(node.id(), futId); add(new NodeFuture(node)); }
/** * @param nodeId Originating node ID. * @param res Response. * @param err Exception. * @return {@code True} if future was completed by this call. */ public boolean checkResponse(UUID nodeId, GridNearTxQueryResultsEnlistResponse res, Throwable err) { assert res != null || err != null : this; if (err == null && res.error() != null) err = res.error(); if (res != null) tx.mappings().get(nodeId).addBackups(res.newDhtNodes()); if (err != null) processFailure(err, null); if (ex != null) { batches.remove(nodeId); if (batches.isEmpty()) // Wait for all pending requests. onDone(); return false; } assert res != null; RES_UPD.getAndAdd(this, res.result()); tx.hasRemoteLocks(true); return true; }
/** * Completeness callback. * * @return {@code True} if future was finished by this call. */ private boolean onComplete() { Throwable err0 = err; if ((!tx.onePhaseCommit() || tx.mappings().get(cctx.localNodeId()) == null) && (err0 == null || tx.needCheckBackup())) tx.state(PREPARED); if (super.onDone(tx, err0)) { // Don't forget to clean up. cctx.mvcc().removeVersionedFuture(this); return true; } return false; }
/** * @param node Primary node. * @throws IgniteCheckedException if future is already completed. */ protected synchronized void updateMappings(ClusterNode node) throws IgniteCheckedException { checkCompleted(); IgniteTxMappings m = tx.mappings(); GridDistributedTxMapping mapping = m.get(node.id()); if (mapping == null) m.put(mapping = new GridDistributedTxMapping(node)); mapping.markQueryUpdate(); if (node.isLocal()) tx.colocatedLocallyMapped(true); checkCompleted(); }
/** * @param cctx Context. * @param tx Transaction. * @param commit Commit flag. */ public GridNearTxFinishFuture(GridCacheSharedContext<K, V> cctx, GridNearTxLocal tx, boolean commit) { super(F.<IgniteInternalTx>identityReducer(tx)); this.cctx = cctx; this.tx = tx; this.commit = commit; ignoreInterrupts(); mappings = tx.mappings(); futId = IgniteUuid.randomUuid(); if (tx.explicitLock()) tx.syncMode(FULL_SYNC); if (log == null) { msgLog = cctx.txFinishMessageLogger(); log = U.logger(cctx.kernalContext(), logRef, GridNearTxFinishFuture.class); } }
/** * Completeness callback. * * @return {@code True} if future was finished by this call. */ private boolean onComplete() { Throwable err0 = err; if ((!tx.onePhaseCommit() || tx.mappings().get(cctx.localNodeId()) == null) && (err0 == null || tx.needCheckBackup())) tx.state(PREPARED); if (super.onDone(tx, err0)) { if (err0 != null) tx.setRollbackOnly(); // Don't forget to clean up. cctx.mvcc().removeVersionedFuture(this); return true; } return false; }
tx.mappings().get(nodeId).addBackups(res.newDhtNodes());
/** * @param cnt Total rows counter on given node. * @param removeMapping Whether transaction mapping should be removed for node. * @param err Exception. * @return {@code True} if future was completed by this call. */ public boolean onResult(long cnt, boolean removeMapping, Throwable err) { synchronized (this) { if (completed) return false; completed = true; } if (X.hasCause(err, ClusterTopologyCheckedException.class) || removeMapping) { GridDistributedTxMapping m = tx.mappings().get(node.id()); assert m != null && m.empty(); tx.removeMapping(node.id()); if (node.isLocal()) tx.colocatedLocallyMapped(false); } else if (err == null && cnt > 0 && !node.isLocal()) tx.hasRemoteLocks(true); return onDone(cnt, err); } }
/** * @param res Response. * @param err Exception. * @return {@code True} if future was completed by this call. */ public boolean onResult(GridNearTxQueryEnlistResponse res, Throwable err) { assert res != null || err != null : this; if (err == null && res.error() != null) err = res.error(); synchronized (this) { if (completed) return false; completed = true; } if (res != null && res.removeMapping()) { GridDistributedTxMapping m = tx.mappings().get(node.id()); assert m != null && m.empty(); tx.removeMapping(node.id()); if (node.isLocal()) tx.colocatedLocallyMapped(false); } else if (res != null) { tx.mappings().get(node.id()).addBackups(res.newDhtNodes()); if (res.result() > 0 && !node.isLocal()) tx.hasRemoteLocks(true); } return err != null ? onDone(err) : onDone(res.result(), res.error()); } }
GridDistributedTxMapping map = tx.mappings().get(nodeId);
/** * @param commit Commit flag. * @return {@code True} if need to send finish request for one phase commit transaction. */ private boolean needFinishOnePhase(boolean commit) { assert tx.onePhaseCommit(); if (tx.mappings().empty()) return false; if (!commit) return true; GridDistributedTxMapping mapping = tx.mappings().singleMapping(); assert mapping != null; return mapping.hasNearCacheEntries(); }
/** * @param node Node. */ private void map(ClusterNode node) { GridDistributedTxMapping mapping = tx.mappings().get(node.id()); if (mapping == null) tx.mappings().put(mapping = new GridDistributedTxMapping(node)); mapping.markQueryUpdate(); if (node.isLocal()) tx.colocatedLocallyMapped(true); int futId = futuresCountNoLock(); miniFutIds.put(node.id(), futId); add(new NodeFuture(node)); }
/** * @param nodeId Originating node ID. * @param res Response. * @param err Exception. * @return {@code True} if future was completed by this call. */ public boolean checkResponse(UUID nodeId, GridNearTxQueryResultsEnlistResponse res, Throwable err) { assert res != null || err != null : this; if (err == null && res.error() != null) err = res.error(); if (res != null) tx.mappings().get(nodeId).addBackups(res.newDhtNodes()); if (err != null) processFailure(err, null); if (ex != null) { batches.remove(nodeId); if (batches.isEmpty()) // Wait for all pending requests. onDone(); return false; } assert res != null; RES_UPD.getAndAdd(this, res.result()); return true; }
/** * @param node Primary node. * @throws IgniteCheckedException if future is already completed. */ protected synchronized void updateMappings(ClusterNode node) throws IgniteCheckedException { checkCompleted(); IgniteTxMappings m = tx.mappings(); GridDistributedTxMapping mapping = m.get(node.id()); if (mapping == null) m.put(mapping = new GridDistributedTxMapping(node)); mapping.markQueryUpdate(); if (node.isLocal()) tx.colocatedLocallyMapped(true); }
/** * @param cctx Context. * @param tx Transaction. * @param commit Commit flag. */ public GridNearTxFinishFuture(GridCacheSharedContext<K, V> cctx, GridNearTxLocal tx, boolean commit) { super(F.<IgniteInternalTx>identityReducer(tx)); this.cctx = cctx; this.tx = tx; this.commit = commit; ignoreInterrupts(); mappings = tx.mappings(); futId = IgniteUuid.randomUuid(); if (tx.explicitLock()) tx.syncMode(FULL_SYNC); if (log == null) { msgLog = cctx.txFinishMessageLogger(); log = U.logger(cctx.kernalContext(), logRef, GridNearTxFinishFuture.class); } }
/** * @param cnt Total rows counter on given node. * @param removeMapping Whether transaction mapping should be removed for node. * @param err Exception. * @return {@code True} if future was completed by this call. */ public boolean onResult(long cnt, boolean removeMapping, Throwable err) { synchronized (this) { if (completed) return false; completed = true; } if (X.hasCause(err, ClusterTopologyCheckedException.class) || removeMapping) { GridDistributedTxMapping m = tx.mappings().get(node.id()); assert m != null && m.empty(); tx.removeMapping(node.id()); if (node.isLocal()) tx.colocatedLocallyMapped(false); } else if (err == null && cnt > 0 && !node.isLocal()) tx.hasRemoteLocks(true); return onDone(cnt, err); } }