/** {@inheritDoc} */ @Override protected IgniteCacheExpiryPolicy accessPolicy( GridCacheContext ctx, IgniteTxKey key, @Nullable ExpiryPolicy expiryPlc) { assert optimistic(); IgniteCacheExpiryPolicy plc = ctx.cache().expiryPolicy(expiryPlc); if (plc != null) { if (accessMap == null) accessMap = new HashMap<>(); accessMap.put(key, plc); } return plc; }
/** {@inheritDoc} */ @Override protected GridCacheEntryEx entryEx(GridCacheContext cacheCtx, IgniteTxKey key) { if (cacheCtx.isColocated()) { IgniteTxEntry txEntry = entry(key); if (txEntry == null) return cacheCtx.colocated().entryExx(key.key(), topologyVersion(), true); GridCacheEntryEx cached = txEntry.cached(); assert cached != null; if (cached.detached()) return cached; if (cached.obsoleteVersion() != null) { cached = cacheCtx.colocated().entryExx(key.key(), topologyVersion(), true); txEntry.cached(cached); } return cached; } else return cacheCtx.cache().entryEx(key.key()); }
/** {@inheritDoc} */ @Override public boolean onDone(IgniteInternalTx tx0, Throwable err) { if (isDone()) return false; synchronized (this) { if (isDone()) return false; if (err != null) { tx.commitError(err); boolean marked = tx.setRollbackOnly(); if (err instanceof IgniteTxRollbackCheckedException) { if (marked) { try { tx.rollback(); } catch (IgniteCheckedException ex) { U.error(log, "Failed to automatically rollback transaction: " + tx, ex); } } } else if (tx.implicit() && tx.isSystemInvalidate()) { // Finish implicit transaction on heuristic error. try { tx.close(); } catch (IgniteCheckedException ex) { U.error(log, "Failed to invalidate transaction: " + tx, ex); } } } if (initialized() || err != null) { if (tx.needCheckBackup()) { assert tx.onePhaseCommit(); if (err != null) err = new TransactionRollbackException("Failed to commit transaction.", err); try { tx.finish(err == null); } catch (IgniteCheckedException e) { if (err != null) err.addSuppressed(e); else err = e; } } if (tx.onePhaseCommit()) { boolean commit = this.commit && err == null; finishOnePhase(commit); tx.tmFinish(commit); } if (super.onDone(tx0, err)) { if (error() instanceof IgniteTxHeuristicCheckedException) { AffinityTopologyVersion topVer = tx.topologyVersion(); for (IgniteTxEntry e : tx.writeMap().values()) { GridCacheContext cacheCtx = e.context(); try { if (e.op() != NOOP && !cacheCtx.affinity().localNode(e.key(), topVer)) { GridCacheEntryEx entry = cacheCtx.cache().peekEx(e.key()); if (entry != null) entry.invalidate(null, tx.xidVersion()); } } catch (Throwable t) { U.error(log, "Failed to invalidate entry.", t); if (t instanceof Error) throw (Error) t; } } } // Don't forget to clean up. cctx.mvcc().removeFuture(futId); return true; } } } return false; }
/** @throws IgniteCheckedException If query is invalid. */ public void validate() throws IgniteCheckedException { if ((type != SCAN && type != SET) && !GridQueryProcessor.isEnabled(cctx.config())) throw new IgniteCheckedException("Indexing is disabled for cache: " + cctx.cache().name()); }