/** * @param ctx Cache registry. * @param implicit Implicit flag. * @param implicitSingle Implicit with one key flag. * @param concurrency Concurrency. * @param isolation Isolation. * @param timeout Timeout. * @param invalidate Invalidation policy. * @param syncCommit Synchronous commit flag. * @param syncRollback Synchronous rollback flag. * @param swapEnabled Whether to use swap storage. * @param storeEnabled Whether to use read/write through. */ GridNearTxLocal( GridCacheContext<K, V> ctx, boolean implicit, boolean implicitSingle, GridCacheTxConcurrency concurrency, GridCacheTxIsolation isolation, long timeout, boolean invalidate, boolean syncCommit, boolean syncRollback, boolean swapEnabled, boolean storeEnabled) { super( ctx, ctx.versions().next(), implicit, implicitSingle, concurrency, isolation, timeout, invalidate, swapEnabled, storeEnabled); assert ctx != null; this.syncCommit = syncCommit; this.syncRollback = syncRollback; }
/** @param m Mapping. */ @SuppressWarnings({"unchecked"}) private void finish(GridDistributedTxMapping<K, V> m) { GridRichNode n = m.node(); assert !m.empty(); GridNearTxFinishRequest req = new GridNearTxFinishRequest<K, V>( futId, tx.xidVersion(), tx.commitVersion(), tx.threadId(), commit, tx.isInvalidate(), m.explicitLock(), tx.topologyVersion(), null, null, null, commit && tx.pessimistic() ? m.writes() : null, tx.syncCommit() && commit || tx.syncRollback() && !commit); // If this is the primary node for the keys. if (n.isLocal()) { req.miniId(GridUuid.randomUuid()); if (CU.DHT_ENABLED) { GridFuture<GridCacheTx> fut = commit ? dht().commitTx(n.id(), req) : dht().rollbackTx(n.id(), req); // Add new future. add(fut); } else // Add done future for testing. add(new GridFinishedFuture<GridCacheTx>(ctx)); } else { MiniFuture fut = new MiniFuture(m); req.miniId(fut.futureId()); add(fut); // Append new future. try { cctx.io().send(n, req); // If we don't wait for result, then mark future as done. if (!isSync() && !m.explicitLock()) fut.onDone(); } catch (GridTopologyException e) { // Remove previous mapping. mappings.remove(m.node().id()); fut.onResult(e); } catch (GridException e) { // Fail the whole thing. fut.onResult(e); } } }
/** * @param entry Transaction entry. * @param nodes Nodes. */ private void map(GridCacheTxEntry<K, V> entry, Collection<GridRichNode> nodes) { GridRichNode primary = CU.primary0(cctx.affinity(entry.key(), nodes)); GridDistributedTxMapping<K, V> t = mappings.get(primary.id()); if (t == null) mappings.put(primary.id(), t = new GridDistributedTxMapping<K, V>(primary)); t.add(entry); }
/** {@inheritDoc} */ @Override public boolean onDone(GridCacheTx tx, Throwable err) { if (initialized() && super.onDone(tx, err)) { // Don't forget to clean up. cctx.mvcc().removeFuture(this); return true; } return false; }
/** * @param cctx Context. * @param tx Transaction. * @param commit Commit flag. */ public GridNearTxFinishFuture( GridCacheContext<K, V> cctx, GridNearTxLocal<K, V> tx, boolean commit) { super(cctx.kernalContext(), F.<GridCacheTx>identityReducer(tx)); assert cctx != null; this.cctx = cctx; this.tx = tx; this.commit = commit; mappings = tx.mappings(); futId = GridUuid.randomUuid(); log = U.logger(ctx, logRef, GridNearTxFinishFuture.class); }
/** @param ctx Context. */ public GridNearCache(GridCacheContext<K, V> ctx) { super(ctx, ctx.config().getNearStartSize()); }
/** @param ctx Cache registry. */ public GridReplicatedCache(GridCacheContext<K, V> ctx) { super(ctx, ctx.config().getStartSize()); }
/** @return DHT cache. */ private GridDhtCache<K, V> dht() { return cctx.near().dht(); }